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

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

相关文章

validates:conclusion,:presence=>true,:inclusion=>{...
一、redis集群搭建redis3.0以前,提供了Sentinel工具来监控各...
分享一下我老师大神的人工智能教程。零基础!通俗易懂!风趣...
上一篇博文 ruby传参之引用类型 里边定义了一个方法名 mo...
一编程与编程语言 什么是编程语言? 能够被计算机所识别的表...
Ruby类和对象Ruby是一种完美的面向对象编程语言。面向对象编...