我不知道什麼時候發生的,但我得到這個錯誤NoMethodError (undefined method 'to_key' for :user:Symbol)
的Heroku,設計:獲取「(用於NoMethodError未定義的方法`TO_KEY」:用戶:符號)」
此行爲僅發生在Heroku上雪松疊加。我使用Devise(1.4.2)通過Facebook上的Rails 3.1.0.rc6和ruby 1.9.2-p290進行身份驗證。它發生在sign_in_and_redirect(:user, authentication.user)
的行上。這是我的方法:
def create
omniauth = request.env['omniauth.auth']
authentication = Authentication.find_by_provider_and_uid(omniauth['provider'], omniauth['uid'])
if !authentication.nil?
flash[:notice] = I18n.t('devise.omniauth_callbacks.success', kind: omniauth['provider'])
sign_in_and_redirect(:user, authentication.user)
elsif current_user
current_user.authentications.create!(provider: omniauth['provider'], uid: omniauth['uid'])
redirect_to profile_path, notice: I18n.t('devise.omniauth_callbacks.success', kind: omniauth['provider'])
else
user = User.new
user.apply_omniauth(omniauth)
if user.save
flash[:notice] = I18n.t('devise.omniauth_callbacks.success', kind: omniauth['provider'])
sign_in_and_redirect(:user, user)
else
session[:omniauth] = omniauth.except('extra')
redirect_to new_user_registration_url
end
end
end
我有同樣的問題,但'未定義的方法'encrypted_password =''。重新啓動也爲我工作 - 謝謝 –
謝謝!我有'NoMethodError(未定義的方法'...'同樣的問題,這解決了我的問題。 –
這樣做的竅門。謝謝! – TinkerTank