[英]No route matches [GET] “/auth/twitter/”
I am working on Ruby on Rails application that can login with Twitter / Facebook account. 我正在研究可以使用Twitter / Facebook帐户登录的Ruby on Rails应用程序。 They was working good until I accidentally use
bundle update
. 在我不小心使用
bundle update
之前,它们工作得很好。
Suddenly I can't run my application since terminal / cmd keep sending me Please add 'devise :omniauthable' to the 'User' model
. 突然我无法运行我的应用程序,因为终端/ cmd不断向我发送消息。
Please add 'devise :omniauthable' to the 'User' model
。
So, I tried to added :omniauthable
, and now the application can run, but when I tried to connect with Facebook or Twitter, I get No route matches [GET] “/auth/twitter/”
因此,我尝试添加
:omniauthable
,现在该应用程序可以运行,但是当我尝试连接Facebook或Twitter时,得到的No route matches [GET] “/auth/twitter/”
Anyone know why this happens? 有人知道为什么会这样吗? I tried to remove
:omniauthable
like said on several questions, but it isn't help. 我试图删除
:omniauthable
就像在几个问题上说的那样,但这无济于事。
user.rb user.rb
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :omniauthable
omniauth.rb omniauth.rb
Rails.application.config.middleware.use OmniAuth::Builder do
provider :twitter, Settings.twitter.key, Settings.twitter.secret
provider :facebook, Settings.facebook.id, Settings.facebook.secret, scope: "email, publish_stream"
end
routes.rb 的routes.rb
# OAuth
get 'auth/:provider/disconnect', to: 'sessions#disconnect'
get 'auth/:provider/callback', to: 'sessions#connect'
get 'auth/failure', to: redirect('/')
get 'signout', to: 'sessions#destroy', as: 'signout'
get 'facebook_disconnect', to: 'user_facebooks#facebook_disconnect', as: 'facebook_disconnect'
get 'twitter_disconnect', to: 'user_twitters#twitter_disconnect', as: 'twitter_disconnect'
Try configuring devise.rb 尝试配置devise.rb
Devise.setup do |config|
config.omniauth :twitter, "TWITTER_KEY", "TWITTER_SECRET"
end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.