omn​​iauth + devise" user / auth / facebook"神奇的路线问题

时间:2011-09-09 17:22:42

标签: ruby-on-rails-3 devise omniauth

在rails 3 app上,我已定义了这些路线:

    devise_for :users, :controllers => {:omniauth_callbacks => "users/omniauth_callbacks", :registrations => 'registrations'}, :path_names => { :sign_in => 'login', :sign_out => 'logout' } do
      get 'login' =>'devise/sessions#new', :as => :new_user_session
      post 'login' => 'devise/sessions#create', :as => :user_session
      get 'signup'  => 'registrations#new', :as => :new_user_registration
      get 'signout' => 'devise/sessions#destroy', :as => :destroy_user_session
    end

    # catchall route to deal with routing errors
    match "*path" => "error#index"

但是,现在当我去log / user / auth / facebook时,它会将我引导到错误页面......

我的解决方案是为最终匹配添加约束:

    match "*path" => "error#index", :constraints => lambda {|req| !req.path.starts_with?("/users/auth/") }

这有效,但我想知道是否有更好的方法......?

1 个答案:

答案 0 :(得分:0)

我认为你最好让404页面处理路由错误。您只能在开发中遇到500错误。这是一部生产中的404。例如,在我的网站上:http://agmprojects.com/test。所以我建议使用公共文件夹中的404.html,而不是加载该控制器。出于好奇,您是否回复了404 http状态代码?