Rails 3 - Oberserver - Not able to user the Devise @current_user
-
26-09-2019 - |
Question
Im building a Rails 3 app, and have an Observer...
in the observer I need to user the current_user var that DEVISE allows me to user across my views...
How can you use the current_user.name or current_user.id in the Observer?
Thank you
Solution
Create User.current accessor, which sets/reads Thread.current[:user]:
http://rails-bestpractices.com/posts/47-fetch-current-user-in-models
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow