accessing devise current_user within model

后端 未结 4 1658
伪装坚强ぢ
伪装坚强ぢ 2021-01-25 16:03

hi i am trying to access current_user within a model for the purpose of creating an element on the fly with find_or_create_by.

the following is the method within my mode

4条回答
  •  渐次进展
    2021-01-25 16:34

    Rails 5.2 introduced current attributes: https://api.rubyonrails.org/classes/ActiveSupport/CurrentAttributes.html

    but as always... you must have in mind that using global states like this might let to some unpredictable behaviour

提交回复
热议问题