我正在构建一个 Rails 3 应用程序,并有一个观察者......
在观察者中,我需要使用 DEVISE 允许我在我的视图中使用的 current_user var...
如何在 Observer 中使用 current_user.name 或 current_user.id?
谢谢
我正在构建一个 Rails 3 应用程序,并有一个观察者......
在观察者中,我需要使用 DEVISE 允许我在我的视图中使用的 current_user var...
如何在 Observer 中使用 current_user.name 或 current_user.id?
谢谢
创建User.current访问器,它设置/读取Thread.current[:user]:
http://rails-bestpractices.com/posts/47-fetch-current-user-in-models