简体   繁体   中英

No route matches [GET] “/auth/twitter/”

I am working on Ruby on Rails application that can login with Twitter / Facebook account. They was working good until I accidentally use bundle update .

Suddenly I can't run my application since terminal / cmd keep sending me 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/”

Anyone know why this happens? I tried to remove :omniauthable like said on several questions, but it isn't help.

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'

Try configuring devise.rb

Devise.setup do |config| 
  config.omniauth :twitter, "TWITTER_KEY", "TWITTER_SECRET"
end

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM