views:

115

answers:

1

This is my first time using the facebooker plugin with rails, and I'm having trouble accessing user info. The website uses FB connect to authenticate users.

I am trying to get the name of the university that the logged in user attends.

When I use the command <%= facebook_session.user.education_history[:name] %>, I get an error "Symbol as array index".

I have also tried using education_history[1], but that just returns "# Facebooker::EducationInfo:<some sort of alphanumeric hash value>"

When I use something like <%= facebook_session.user.relationship_status %> , it returns the relationship status just fine. Similarly, <%= facebook_session.user.hometown_location.city %> returns the city name just fine.

I've checked out the documentation for facebooker, but I can't figure out the correct way to get the values I need.

Any idea on how to get this to work?
Thanks!

A: 

facebook_session.user.education_history returns an array of Facebooker::EducationInfo objects. The proper way to access it would be:

ed = facebook_session.user.education_history.last #Will be nil if not provided
@ed_name = ed.name unless ed.nil?

I am not sure the order they are sorted in, so you may need to call .first instead of .last

Doug Neiner