Short answer, you can't (at least not easily). current_user is a controller method and therefore the model doesn't have access to it (Rails is all about Model-View-Controller separation, remember). There's been a fair amount of discussion on these lists about accessing the user from the model, including a few MVC-breaking workarounds. Quick google should dig them out.
Related topics
Topic | Replies | Views | Activity | |
---|---|---|---|---|
current_user | 0 | 108 | September 23, 2006 | |
How to get current_user when I'm in model | 2 | 1677 | January 24, 2009 | |
current_user | 0 | 81 | September 23, 2006 | |
How can we access current_model (Devise:Here model can be User,Account etc.) method inside AR model? | 8 | 274 | January 26, 2018 | |
Resyful authenticatio current_user in model | 3 | 179 | September 16, 2010 |