0

I'm trying to extract and save in my db, the uid of a Facebook user's Omniauth Authentication.

When I issue the command user.authentications, the resulting array is displayed:

[ < Authentication id: 3, user_id: 63, provider: "facebook", uid: "123456789", created_at: "2012-07-02 02:10:48", updated_at: "2012-07-02 02:10:48" > ]

But when I execute user.authentications.last, to get the above Authentication out of the 1 item array, I receive:

< Authentication:0x007f837d32e288 >

Why doesn't it display all the parameters, id, user_id, provider, uid, etc. I can't access and extract the uid this way. I'm trying to run user.authentications.last.uid.

Thank you

hjaved
  • 1,585
  • 2
  • 10
  • 10
  • how do you call user.authentications if you have not saved to db yet? I save directly from omniauth request – Hishalv Jul 02 '12 at 08:22
  • I'm trying to get an index of all users. Some have signed up via Facebook, others via an email/password form. I give a conditional statement as follows: <%@users.each do |u| %> <%if u.authentications%> <%=u.authentications%> <%=u.name%> <%else%> <%=u.name%> <%end%> <%end%> – hjaved Jul 02 '12 at 18:03

1 Answers1

0

What you see here is simply different string representation of the objects. Array's to_s method gives you a nice printout, but Authentication's to_s does not. Try user.authentications.last.inspect if you just want to look at it.

Dean Brundage
  • 2,038
  • 18
  • 31