grimen / devise_facebook_connectable

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

callbacks not working for me (MongoMapper) #13

Closed bitzesty closed 14 years ago

bitzesty commented 14 years ago

here is my call back, tried a before_fb_connect but still nothing is set. will try and build a bare bones app to demonstrate the prob.

def after_facebook_connect(fb_session)

  # Just fetch what we really need from Facebook...
  fb_session.user.populate(:locale, :current_location, :username, :name,
                            :first_name, :last_name, :birthday_date, :sex,
                            :city, :state, :country, :relationship_status, :proxied_email)

  self.birthdate      = fb_session.user.birthday_date.try(:to_date)
  self.city           = fb_session.user.hometown_location.try(:city)
  self.country        = fb_session.user.hometown_location.try(:country)
  self.first_name     = fb_session.user.first_name
  self.gender         = fb_session.user.sex
  self.last_name      = fb_session.user.last_name
  self.locale         = fb_session.user.locale
  self.real_name      = fb_session.user.name
  self.relationship_status = fb_session.user.relationship_status    
  self.time_zone      = fb_session.user.current_location.try(:city)
  self.username       = fb_session.user.username
  self.zip_code       = fb_session.user.hometown_location.try(:state)
  self.proxied_email  = fb_session.user.proxied_email

  self.save
end
grimen commented 14 years ago

OK, I'm not running MongoDB locally. Yes, please let me know when you got something to test out.

bitzesty commented 14 years ago

i've got no idea why this isn't working, but I have a hack - assigning the fb session value to a random variable then to the user attribute works:

 _x = fb_session.user.name
 self.real_name = _x 
grimen commented 14 years ago

=o That's weird...but I'm 99.9% sure that's not because of this plugin. Sounds like Facebooker magic. Let me know if you find out why please.

bitzesty commented 14 years ago

facebooker lazy loading or something very weird

bitzesty commented 14 years ago

solved it need to call to_s on facebooker atts on the user object or they will not be saved

grimen commented 14 years ago

Could you elaborate what you mean with a sample?

bitzesty commented 14 years ago
  self.username       = fb_session.user.username.to_s
  self.real_name      = fb_session.user.name.to_s

as opposed to

  self.username       = fb_session.user.username
  self.real_name      = fb_session.user.name

otherwise atlease with mongomapper - it saves nil

grimen commented 14 years ago

Could you reproduce this in a test-app? Easier to report errors in Facebooker mailing list in such case; I asked about this but no-one there seems to see the problem.

bitzesty commented 14 years ago

its probably a mongomapper issue - closing