使用Devise和Omniauth的路由问题

我试图让OAuth和Devise一起工作,但我得到Controller::RoutingError (No route matches "/users/auth/facebook/callback"):当试图通过Facebook进行身份validation时。

奇怪的是,Google Apps不会出现此问题。 (相同的回调路线)。

有任何想法吗?

callback_controller:

 class Users::OmniauthCallbacksController  "Facebook" sign_in_and_redirect @user, :event => :authentication else session["devise.facebook_data"] = env["omniauth.auth"] redirect_to new_user_registration_url end end def google_apps @user = User.find_for_google_apps_oauth(env["omniauth.auth"], current_user) if @user.persisted? flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => "Google Apps" sign_in_and_redirect @user, :event => :authentication else session["devise.google_apps_data"] = env["omniauth.auth"] redirect_to new_user_registration_url end end def passthru render :file => "#{Rails.root}/public/404.html", :status => 404, :layout => false end end 

routes.rb中:

 devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" } do get '/users/auth/:provider' => 'users/omniauth_callbacks#passthru' end 

为什么:provider => "facebook"触发RoutingError,但不会:provider => "google_apps"

找到了:

在设计用户模型中,我有模块:: :omniauth_providers => [:facebook, :openid, :google_apps]添加了(显然)没有做我认为它做的事情。 我删除了该行,现在我的所有auth逻辑再次正常工作。