我正在开发可以使用Twitter / Facebook帐户登录的Ruby on Rails应用程序。他们工作得很好,直到我不小心使用bundle update
。
突然之间我无法运行我的应用程序,因为终端/ cmd一直向我发送Please add 'devise :omniauthable' to the 'User' model
。
所以,我试图添加:omniauthable
,现在应用程序可以运行,但当我尝试连接Facebook或Twitter时,我得到No route matches [GET] “/auth/twitter/”
任何人都知道为什么会这样吗?我尝试删除:omniauthable
,就像在几个问题上所说的那样,但它没有帮助。
user.rb
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :omniauthable
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
# 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'
答案 0 :(得分:0)
尝试配置devise.rb
Devise.setup do |config|
config.omniauth :twitter, "TWITTER_KEY", "TWITTER_SECRET"
end