Migrating to OmniAuth 1.0: undefined method `user_omniauth_authorize_path '

Trying to port my application from Rails 3.0 to 3.2 , and as part of this I am also updating the gem. It turned out that the new developer needed a new OmniAuth gem. I have Facebook authorization configured with OmniAuth . After reading the migration guide, I also added omniauth-facebook gem and configured it in devise.rb.

Now I get this error:

ActionView :: Template :: Error (undefined method `user_omniauth_authorize_path 'for # & L; #: 0x00000003b01e88>)

I used this path to log in to Facebook. What should i use now?

The user model contains this (user.rb):

# Include default devise modules. Others available are: # :token_authenticatable, :confirmable, :lockable and :timeoutable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable, :omniauthable 

Full server log:

 Started GET "/" for 127.0.0.1 at 2012-02-22 10:39:27 +0200 Processing by PagesController#guardian as HTML [paperclip] Duplicate URL for photo with /system/:attachment/:id/:style/:filename. This will clash with attachment defined in Asset class Rendered pages/guardian.html.erb within layouts/application (955.6ms) Completed 500 Internal Server Error in 1245ms ActionView::Template::Error (undefined method `user_omniauth_authorize_path' for #<#<Class:0x00000003b213f0>:0x00000003b01e88>): 30: </p> 31: </td> 32: <td> 33: <%= link_to "Login with Facebook", user_omniauth_authorize_path(:facebook), :class => "login_with_facebook_button" %> 34: </td> 35: </tr> 36: </table> app/views/pages/guardian.html.erb:33:in `_app_views_pages_guardian_html_erb___1979224720320394612_27892940' 

Update: Ok, I was able to solve this problem. Now, when you click the Facebook login button, I get the following:

 Started GET "/users/auth/facebook" for 127.0.0.1 at 2012-02-23 16:02:01 +0200 NoMethodError (undefined method `include?' for nil:NilClass): omniauth (1.0.2) lib/omniauth/strategy.rb:165:in `call!' omniauth (1.0.2) lib/omniauth/strategy.rb:148:in `call' warden (1.1.1) lib/warden/manager.rb:35:in `block in call' warden (1.1.1) lib/warden/manager.rb:34:in `catch' warden (1.1.1) lib/warden/manager.rb:34:in `call' 

All this is a bit confusing. The path problem is resolved after I determined: facebook params accodring to this tutorial: https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview . Now I also noticed that I miss omniauth.rb from the config / initializers folder mentioned in the omniauth-facebook wiki. I created omniauth.rb with the following content, but still getting the same problem:

 Rails.application.config.middleware.use OmniAuth::Builder do provider :facebook, ENV['APP_ID'], ENV['APP_SECRET'] end 
+7
source share
2 answers

I solved this problem by running the generators again. Two files to check: config / routes.rb and models / user.rb

There will be a duplicate of "devise_for" in the routes.rb file in the upper right, and user.rb will have modules by default, so here you need to add "omniauthable".

+5
source

Put the construct: omniauthable on the user model. My current versions are devise 2.0.4, omniauth 1.1.0, and omniauth-facebook 1.2.0

+4
source

All Articles