Instead of using resource_class.omniauth_providers
, you could try Devise.omniauth_providers
if you're ok with a reference to Devise in your view (it's perhaps not as nice as going via the resource_class). It will return the same list of providers, assuming that the ones you've set up using the config.omniauth
parameter in your devise.rb
initialiser are the same as the :omniauth_providers
list in your user model. If not, or if you have multiple user model classes and they don't all allow login using the same providers and so have different :omniauth_providers
listed, then this wouldn't be appropriate for you but I'm guessing that's unlikely.
How to use `resource_class.omniauth_providers` outside devise view template?
-
12-10-2022 - |
Pregunta
I'm using resource_class
in devise view partial template like this.
<%- resource_class.omniauth_providers.each do |provider| %>
<%= link_to "Connect to #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider), class: "#{provider.to_s} omniauth" %>
<% end -%>
It works fine. But when I load this partial from another model's view, I get this error.
undefined local variable or method `resource_class' for #<#<Class:0x007fa29be245d8>:0x007fa29bdf3708>
What should I do to use resource_class
from another model's view?
I want to make user possible to signup everywhere in my app with modal dialog.
Solución
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow