Heroku,Devise:获取'NoMethodError(未定义的方法`to_key'for:user:Symbol)'

Iva*_*van 6 ruby authentication heroku devise ruby-on-rails-3

我不知道它什么时候发生但是我收到了这个错误 NoMethodError (undefined method 'to_key' for :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
Run Code Online (Sandbox Code Playgroud)

sha*_*dar 9

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

$ cd your_app_directory
$ heroku restart
Run Code Online (Sandbox Code Playgroud)

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