我遇到了问题,我按照本教程: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)后点击链接时出现此错误:
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
答案 0 :(得分:0)
有效!我用设计做到了。但只是不要忘记安装“mongoid”宝石以设置设计(这花了我很多时间来确定mogoid丢失)。
谢谢大家!