2014-02-15 82 views
2

我有问题omniauth-google-oath2宝石。Google omniauth无法识别路径

我的代码:

devise.rb

config.omniauth :google_oauth2, 'app_id','secret' 

omniauth_callbacks_controller.rb

def google_oauth2 
    auth = env["omniauth.auth"] 

    @user = User.find_for_google_oauth2(request.env["omniauth.auth"], current_user) 
    if @user.persisted? 
    flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => "Google" 
    sign_in_and_redirect @user, :event => :authentication 
    else 
    session["devise.google_uid"] = request.env["omniauth.auth"] 
    redirect_to new_user_registration_url 
    end 
end 

我也在我user.rb模型提供find_for_google_oauth2方法。 在我html.erb我写道:

<%= link_to "With Google", user_omniauth_authorize_path(:google_oauth2) %> 

而在最后,我有这样的错误:没有路由匹配{:控制器=> “omniauth_callbacks”:动作=> “中继”:供应商=> :google_oauth2,:format => nil}缺少必需的密钥:[:provider]

我的错误在哪里? 感谢您的任何提前!

回答

0

我解决了我的问题。这是愚蠢的:) 我刚刚重新启动我的本地导轨服务器,一切工作正常。

4

检查

devise :omniauthable, omniauth_providers: [:google_oauth2] 

它可能丢失或错误的用户模型。

相关问题