I use omniauth-facebook and get information about users with this function in user.rb
def self.find_for_facebook_oauth(auth, signed_in_resource=nil)
user = User.where(:provider => auth.provider, :uid => auth.uid).first
unless user
user = User.create(name: auth.extra.raw_info.first_name,
surname: auth.extra.raw_info.last_name,
provider: auth.provider,
uid: auth.uid,
email: auth.info.email,
password: Devise.friendly_token[0, 20],
# City: auth.extra.raw_info.location.name,
state: auth.extra.raw_info.locale.gsub(/_/, '-'),
gender: auth.extra.raw_info.gender,
language: auth.extra.raw_info.language|| { },
bio: auth.extra.raw_info.bio|| { },
work: auth.extra.raw_info.work|| { } ,
education: auth.extra.raw_info.education|| { })
end
user
end
but auth.extra.raw_info.education|| { }, work: auth.extra.raw_info.work|| { }
, returns me something like this:
---
- !ruby/hash:OmniAuth::AuthHash
school: !ruby/hash:OmniAuth::AuthHash
id: '115686675112108'
name: istituto magistrale
type: High School
- !ruby/hash:OmniAuth::AuthHash
school: !ruby/hash:OmniAuth::AuthHash
id: '134968379850136'
name: laurea in pedagogia
year: !ruby/hash:OmniAuth::AuthHash
id: '116957165019970'
name: '1986'
type: College
I do not know if it is an array or what, my field of education is a string, how do I access school, name, year or type?
If I try auth.extra.raw_info.education.name
it says impossible convert integer to string