4
我有一个current_user
方法来处理身份验证。找不到id = 1的用户
application_controller.rb
protect_from_forgery
helper_method :current_user
def current_user
@current_user ||= User.find(session[:user_id]) if session[:user_id]
end
,但是当我尝试存取权限一个一个网页,我得到了以下错误:
Couldn't find User with id=1
app/controllers/application_controller.rb:10:in `current_user'
如何传递@current_user
一种默认值,所以如果没有用户,它将重定向到登录页面。
感谢您的帮助。
Thans for helping.I guess that old data was from a migration mess I've reset reset migration multiple。 – 2011-12-15 21:41:33