Google 身份验证错误 "no route match"
Google authentification error "no route match"
我有问题,我按照这个教程:https://richonrails.com/articles/google-authentication-in-ruby-on-rails。
除了rails g controller home show
我什么都做了,因为我已经有一个static_pages控制器和home.html.erb
所以在我的 route.rb
中,我已经替换了教程中的这一行:
resource :home, only: [:show]
root to: "home#show"
来自
resource :static_pages, only: [:home]
root to: 'static_pages#home'
但是当我在启动服务器 (localhost) 后单击 link 时出现此错误:
No route matches [GET] "/auth/google_oauth2"
你知道这个问题吗?希望你能帮助我。
提前致谢。
编辑:我的 route.rb 代码
Rails.application.routes.draw do
get 'sessions/create'
get 'sessions/destroy'
get 'sessions/new'
get 'users/new'
root 'static_pages#home'
get 'help' => 'static_pages#help'
get 'about' => 'static_pages#about'
get 'contact' => 'static_pages#contact'
get 'signup' => 'users#new'
get 'login' => 'sessions#new'
post 'login' => 'sessions#create'
delete 'logout' => 'sessions#destroy'
resources :users
end
GoogleAuthExample::Application.routes.draw do
get 'auth/:provider/callback', to: 'sessions#create'
get 'auth/failure', to: redirect('/')
get 'signout', to: 'sessions#destroy', as: 'signout'
resources :sessions, only: [:create, :destroy]
resource :static_pages, only: [:home]
root to: 'static_pages#home'
end
有效!我用设计来做到这一点。但不要忘记安装 "mongoid" gem 以设置设计(这花了我很多时间来确定缺少 mogoid)。
谢谢大家!
我有问题,我按照这个教程:https://richonrails.com/articles/google-authentication-in-ruby-on-rails。
除了rails g controller home show
我什么都做了,因为我已经有一个static_pages控制器和home.html.erb
所以在我的 route.rb
中,我已经替换了教程中的这一行:
resource :home, only: [:show]
root to: "home#show"
来自
resource :static_pages, only: [:home]
root to: 'static_pages#home'
但是当我在启动服务器 (localhost) 后单击 link 时出现此错误:
No route matches [GET] "/auth/google_oauth2"
你知道这个问题吗?希望你能帮助我。
提前致谢。
编辑:我的 route.rb 代码
Rails.application.routes.draw do
get 'sessions/create'
get 'sessions/destroy'
get 'sessions/new'
get 'users/new'
root 'static_pages#home'
get 'help' => 'static_pages#help'
get 'about' => 'static_pages#about'
get 'contact' => 'static_pages#contact'
get 'signup' => 'users#new'
get 'login' => 'sessions#new'
post 'login' => 'sessions#create'
delete 'logout' => 'sessions#destroy'
resources :users
end
GoogleAuthExample::Application.routes.draw do
get 'auth/:provider/callback', to: 'sessions#create'
get 'auth/failure', to: redirect('/')
get 'signout', to: 'sessions#destroy', as: 'signout'
resources :sessions, only: [:create, :destroy]
resource :static_pages, only: [:home]
root to: 'static_pages#home'
end
有效!我用设计来做到这一点。但不要忘记安装 "mongoid" gem 以设置设计(这花了我很多时间来确定缺少 mogoid)。
谢谢大家!