谷歌omniauth不承认路径

Shy*_*mov 2 omniauth ruby-on-rails-4

我有omn​​iauth-google-oath2 gem的问题.

我的代码:

devise.rb

config.omniauth :google_oauth2, 'app_id','secret'
Run Code Online (Sandbox Code Playgroud)

omn​​iauth_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
Run Code Online (Sandbox Code Playgroud)

我还在user.rb模型中提供了find_for_google_oauth2的方法.在我的html.erb中,我写道:

<%= link_to "With Google", user_omniauth_authorize_path(:google_oauth2) %>
Run Code Online (Sandbox Code Playgroud)

最后我有这个错误:没有路由匹配{:controller =>"omniauth_callbacks",:action =>"passthru",:provider =>:google_oauth2,:format => nil}缺少必需的密钥:[:provider]

我的错误在哪里?谢谢你的任何进步!

coo*_*sse 5

检查用户模型

devise :omniauthable, omniauth_providers: [:google_oauth2]
Run Code Online (Sandbox Code Playgroud)

它可能是缺失或错误的.