Note that there are some explanatory texts on larger screens.

plurals
  1. POSession problem using Facebooker with Ruby on Rails
    primarykey
    data
    text
    <p>I am reading the book Facebook Platform Development in order to try to code a small game for Facebook, and I have come across a "little" problem: I am trying to insert a user every time this is logged, into a database in my computer. I am using a couple of methods written in the book, but there seems to be a couple of problems: </p> <ol> <li><p>I can't seem to retrieve the session_key from Facebook using the Facebooker helpers for RoR, and thus this value is null into the table in my database.</p></li> <li><p>Every time I reload the webpage, I can see that even though the facebook_id is the same, the same user is added in another row to my table in the database, even though it shouldn't; it's just supposed to update the attribute session_key if this changes -anyway, right now this is null.</p></li> </ol> <p>These are the three methods I am using in order to perform all this:</p> <pre><code>def self.for(facebook_id,facebook_session=nil) user = User.find_or_create_by_facebook_id(facebook_id) unless facebook_session.nil? user.store_session(facebook_session.session_key) end end def store_session(session_key) if self.session_key != session_key update_attribute(:session_key, session_key) end end # Re-create a Facebooker::Session object outside a request def facebook_session @facebook_session ||= returning Facebooker::Session.create do |session| # Facebook sessions are good for only one hour storing session.secure_with!(session_key,facebook_id,1.hour.from_now) end end </code></pre> <p>Thanks a lot in advance to everybody!1.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload