为没有STI的多个模型设计Omniauth

mar*_*rna 9 ruby-on-rails devise omniauth

有没有办法为没有STI的多个模型配置Devise Omniauth?

我们有模特学生和教授,我们不想使用STI,但现在我们意识到Devise with Omniauth不适合多种模式.

.rvm/gems/ruby-1.9.3-p125/gems/devise-2.1.0/lib/devise/rails/routes.rb:384:in `devise_omniauth_callback': Wrong OmniAuth configuration. If you are getting this exception, it means that either: (RuntimeError)

1) You are manually setting OmniAuth.config.path_prefix and it doesn't match the Devise one
2) You are setting :omniauthable in more than one model
3) You changed your Devise routes/OmniAuth setting and haven't restarted your server
Run Code Online (Sandbox Code Playgroud)

San*_*ing 1

我认为而不是写给:omniauthable个人Student& Professor model。您应该生成第三个模型并为其Omniuser添加设置。:omniauthable

class Student < ActiveRecord::Base
  has_one :omniuser
end

class Professor < ActiveRecord::Base
  has_one :omniuser
end
Run Code Online (Sandbox Code Playgroud)