grimen / devise_facebook_connectable

Devise << Facebook Connect. IMPORTANT: Not maintained anymore.
MIT License
146 stars 20 forks source link

facebook_sign_in_link helper causes NoMethodError in Ruby 1.9.1 #16

Closed szimek closed 14 years ago

szimek commented 14 years ago

The problem is actually in facebook_connect_form helper. scope = ::Devise::Mapping.find_by_path(request.path).to rescue scope Devise::Mapping.find_by_path(arg).to return a class i.e. User. When form_for(scope) is called later, it actually calls form_for(User) and Rails tries to call dom_id method on User, which in turn calls #id method. In Ruby 1.8 it raises just a warning, but in 1.9 this method is missing.

I'm not sure why this form is needed inside facebook_sign_in_link at all, but switching from #to to #name method in the line mentioned above fixes the problem.

grimen commented 14 years ago

That line tries to auto-detect scope. Uhm...without the form you won't get a Devise session, logging in on Facebook is just not enough. What version of Devise you use? Devise moved forward quite fast so the API might have changed, will have a look later on. Use Devise <= 1.0.0, I won't support newer one yet myself as it's built for Rails 3 only and Rails is....beta.

szimek commented 14 years ago

I'm not saying that this line should be removed completely :) I'm just saying that it should be changed from: scope = ::Devise::Mapping.find_by_path(request.path).to rescue scope which for url /users/sign_up returns User class, to: scope = ::Devise::Mapping.find_by_path(request.path).name rescue scope which returns :user symbol :)

szimek commented 14 years ago

I edited my original post to include a patch, but it got lost somehow... Here it is again: szimek/devise_facebook_connectable@1fa5b5c08b670caba6d22d14afa92bf42dff519e

grimen commented 14 years ago

OK, thanks!

grimen commented 14 years ago

Fixed old bug where incorrect scope gets auto-detected. Closed by 2d9b2d73c41bc1d75082f6642102dc26383cc30a