2013-12-19 47 views
0

三週前我的應用工作正常,但返回工作後,我在嘗試通過Facebook登錄後出現此錯誤:Omniauth錯誤:沒有路由匹配[GET]「/ auth/facebook」

No route matches [GET] "/auth/facebook" 

不知道發生了什麼事。我看過Stackoverflow,但發現只有與Devise gem相關的幫助。

注意:我沒有使用Devise gem。

我的應用程序是關於Ruby 2.0和Rails 4

我gemlock文件顯示這些版本omniauth的:

oauth2 (0.8.1) 
     faraday (~> 0.8) 
     httpauth (~> 0.1) 
     jwt (~> 0.1.4) 
     multi_json (~> 1.0) 
     rack (~> 1.2) 
    omniauth (1.1.4) 
     hashie (>= 1.2, < 3) 
     rack 
    omniauth-facebook (1.4.0) 
     omniauth-oauth2 (~> 1.0.2) 
    omniauth-oauth2 (1.0.3) 
     oauth2 (~> 0.8.0) 
     omniauth (~> 1.0) 

這裏是我的routes.rb:

Mybrary::Application.routes.draw do 
    get "sessions/create" 
    get "sessions/destroy" 
    resources :users do 
    resources :items, except: [:index] 
    end 


    resources :groups 
    root 'users#splash' 


    get 'items/search' => 'items#search_results', as: :search_item 

    post 'user/:id/requests/:item_id' => 'users#request_loan', as: :request_loan 
    post 'user/:id/approves/:item_id' => 'users#approve_loan', as: :approve_loan 
    post 'user/:id/denies/:item_id' => 'users#deny_loan', as: :deny_loan 
    post 'user/:id/returns/:item_id' => 'users#return_loan', as: :return_loan 

    post 'group/:id/join_group/:user_id' => 'groups#join_group', as: :join_group 
    post 'group/:id/leave_group/:user_id' => 'groups#leave_group', as: :leave_group 

    post 'group/:id/approve_member/:user_id' => 'groups#approve_member', as: :approve_member 
    post 'group/:id/deny_member/:user_id' => 'groups#deny_member', as: :deny_member 


    match 'auth/:provider/callback', to: 'sessions#create', via: [:get, :post] 
    match 'auth/failure', to: redirect('/'), via: [:get, :post] 
    match 'signout', to: 'sessions#destroy', as: 'signout', via: [:get, :post] 
end 

回答

2

相反這一個

match 'auth/:provider/callback', to: 'sessions#create', via: [:get, :post] 
match 'auth/failure', to: redirect('/'), via: [:get, :post] 
match 'signout', to: 'sessions#destroy', as: 'signout', via: [:get, :post] 

試試這個

get 'auth/:provider/callback' => 'sessions#create' 
get 'auth/failure' => redirect('/') 
get 'signout' => 'sessions#destroy', as: 'signout' 
+0

嗨Jiten。我在別處見過這個答案,但我不確定它是否適用於我,因爲我沒有使用Devise gem。我沒有一個'omniauthable'來評論。 – SamTalks

+0

我很感激你刪除了第二部分的路線,但我仍然無法將它添加到我的初始化程序中。我創建了config/initializers/omniauth.rb並輸入了您放入的代碼,重新啓動Rails服務器,錯誤仍然相同。 – SamTalks

+0

請嘗試我把它放在答案框 – jimagic

相關問題