Access Devise's current_user in Model

前端 未结 1 1332
日久生厌
日久生厌 2021-01-01 15:11

How do I go about accessing Devises \'current_user\' object inside of a model? I want to automatically append the current users id to a record when they create something. I

相关标签:
1条回答
  • 2021-01-01 15:41

    Essentially, this kind of logic doesn't belong in a Model, so you're best to pass current_user in through a function in the model or on creation. This answer sums it up.

    I know, I know, that's not the answer you wanted. Unfortunately, it may be cleaner looking to you, but it adds overhead to your model that you really don't want.

    0 讨论(0)
提交回复
热议问题