Devise Omniauth undefined method omniauth_authorize_path

kambi picture kambi · Sep 25, 2013 · Viewed 8.8k times · Source

I've noticed that when logging to Devise I have started to receive these error message.

I'm using Devise 2.2.4 with Omniauth 1.1.4 and Omniauth-Facebook 1.4.1

Does anybody know what is the cause of this error?

  ActionView::Template::Error (undefined method `omniauth_authorize_path' for #<#<Class:0xb85e534>:0xb904e5c>):
21: <%- if devise_mapping.omniauthable? %>
22:   <%- resource_class.omniauth_providers.each do |provider| %>
23:     <% logger.info "hey #{provider} , dolphin and #{resource_name}" %>
24:     <%= link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider) %><br />
25:   <% end -%>
26: <% end -%>

  app/views/devise/shared/_links.erb:24:in `block in _app_views_devise_shared__links_erb___1039642231_94147460'
  app/views/devise/shared/_links.erb:22:in `each'
  app/views/devise/shared/_links.erb:22:in `_app_views_devise_shared__links_erb___1039642231_94147460'
  app/views/devise/sessions/new.html.erb:17:in `_app_views_devise_sessions_new_html_erb__883448937_92868060'

Answer

lulalala picture lulalala · Dec 16, 2013

One possible mistake is that omniauth configuration is set at the wrong place.

I encountered this error because I set my facebook accounts in config/initializers/omniauth.rb, as instructed by the omniauth readme.

However we need to set it through devise, i.e. config/initializers/devise.rb at the omniauth section.