Devise, Omniauth and multiple models with STI

[亡魂溺海] 提交于 2020-01-14 14:41:31

问题


I have an application setup with devise authentication using sti (base user model and two other models - company and individual - inheriting from it). From a devise perspective, everything is working. I can have different routes for signup forms and everything works as expected. Now I wanted to give both users (company and individual) the option to signup/sign in using facebook or linked in. If I set the :omniauthable on both models, and set the devise_for on my routes.rb for each model, I get an error saying that only one model can be omniauthable. If I don't use the devise_for for each model, no routes are generated. If I set the omniauthable on user model only, I get only one route and one callback.

I've read somewhere that the solution would be to use omniauth on its own (separated from devise). However, I can't seem to achieve the intended behavior using omniauth separate from devise (I can get one single authorize/callback route, but the two, as intended).

Anyone out there who can help ?

TIA


回答1:


Devise's Omniauthable module does support multiple models. See

https://github.com/plataformatec/devise/wiki/OmniAuth-with-multiple-models



来源:https://stackoverflow.com/questions/15496680/devise-omniauth-and-multiple-models-with-sti

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