Facebooker and Ruby on Rails on Facebook: Sessions problem

Hello everybody,

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:

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.

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.

These are the three methods I am using in order to perform all this:

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

Thanks a lot in advance to everybody!