2014-02-15 81 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] 

它可能丟失或錯誤的用戶模型。

相關問題