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