grimen / devise_facebook_connectable

Devise << Facebook Connect. IMPORTANT: Not maintained anymore.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

callbacks not working for me (MongoMapper)

opened this issue · comments

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

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

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 

=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.

facebooker lazy loading or something very weird

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

Could you elaborate what you mean with a sample?

  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

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.

its probably a mongomapper issue - closing