我的应用程序在三周前工作正常,但在重新开始工作后,我在尝试通过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
答案 0 :(得分: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'