Why is Devise's “current_user” not available at the model layer?

混江龙づ霸主 提交于 2019-12-23 10:03:17

问题


There are many posts about Devise and the lack of availability of "current_user" for use in models. There are numerous work arounds posted here and elsewhere. However, i haven't found the answer to "why" in any of the posts. Is this a security issue? If not, why?


回答1:


Because you don't have access to a session variable inside a model, it's not a Devise issue or something related to security. It's related to the MVC pattern used in Rails.



来源:https://stackoverflow.com/questions/5884132/why-is-devises-current-user-not-available-at-the-model-layer

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