ruby – Heroku,Devise:获取’NoMethodError(未定义方法`to_key’for:user:Symbol)’

前端之家收集整理的这篇文章主要介绍了ruby – Heroku,Devise:获取’NoMethodError(未定义方法`to_key’for:user:Symbol)’前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我不知道它什么时候发生但我得到这个错误NoMethodError(未定义的方法’to_key’为:user:Symbol)

此行为仅发生在Heroku Cedar堆栈上.我使用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

解决方法

在本地计算机上执行任何操作之前,请先尝试重新启动heroku:
$cd your_app_directory
$heroku restart

我有完全相同的问题,并简单的重新启动修复它.

原文链接:https://www.f2er.com/ruby/264974.html

猜你在找的Ruby相关文章