[英]Devise Error on upgrading to rails 4.2
目前,我正在使用Rails 4.0.8来实现我的Rails应用程序。 现在我想升级到Rails 4.2,在我的这个应用程序中,我正在使用Devise和OmniAuth进行身份验证,并且可以在Rails 4.0.8上正常工作。 现在,当我尝试升级到Rails 4.2.3时,我的身份验证系统突然停止工作。 它给出了以下错误
ArgumentError at /users/auth/facebook/callback
wrong number of arguments (2 for 1) and it is pointing to the line in controller sign_in_and_redirect(user)
我的OmniAuth回调控制器的代码是:
class OmniauthCallbacksController < Devise::OmniauthCallbacksController
skip_before_filter :authenticate_user!
def all
p env["omniauth.auth"]
user = User.from_omniauth(env["omniauth.auth"], current_user)
if user.persisted?
flash[:notice] = "You are in..!!! Go to edit profile to see the status for the accounts"
sign_in_and_redirect(user)
else
session["devise.user_attributes"] = user.attributes
redirect_to new_user_registration_url
end
end
def failure
#handle you logic here..
#and delegate to super.
super
end
alias_method :facebook, :all
alias_method :google_oauth2, :all
end
sign_in_and_redirect()方法中的问题,它允许两个参数resource
和event
,将代码修复为:
def all
p env["omniauth.auth"]
user = User.from_omniauth(env["omniauth.auth"], current_user)
if user.persisted?
flash[:notice] = "You are in..!!! Go to edit profile to see the status for the accounts"
sign_in_and_redirect(user, event: :authentication)
else
session["devise.user_attributes"] = user.attributes
redirect_to new_user_registration_url
end
end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.