Authlogic's current_user object in models

蹲街弑〆低调 提交于 2019-12-03 13:00:59

assuming the user is loggedin you can use

UserSession.find.user

You might want to add checks to ensure UserSession.find returns something before calling .user

It's not possible.
The current_user relies on the session, which isn't available in the model (and that's normal. The models are context-independent).

You should pass the user to the model as a parameter.

The best way to access the current_user in the Model(s) when using Authlogic is using Sentiant User - https://github.com/bokmann/sentient_user There is a full documentation on the there how to use it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!