Omniauth “with” STI and devise

北战南征 提交于 2019-12-04 20:57:41

The answer can be found here.

Devise gets mixed up since you are calling devise_for for three different models and one of them is using the omniauthable module.

Either:

  1. Remove all devise_for methods except for :users.

  2. Or remove the omniauthable module from the user model, create your own omniauth routes and stop using devise's middleware by moving your omniauth configuration into a new file. So, instead of having this in devise.rb:

    Devise.setup do |config|
      config.omniauth :twitter, ENV['TWITTER_KEY'], ENV['TWITTER_SECRET']
    end
    

    You now have this in your new file omniauth.rb:

    Rails.application.config.middleware.use OmniAuth::Builder do
      provider :twitter, ENV['TWITTER_KEY'], ENV['TWITTER_SECRET']
    end
    

    The Railscast on Simple OmniAuth should help you setting this up.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!