Restful_authentication+ personnalized database session store

I’m using restful_authentication and database session store with rails
2.1.0. It works well and I’m trying too add the user_id in the session
table.
For that, I have created app/models/session.rb and I have set the
user_id value in app/controllers/sessions_controller.rb when the user is
logged in:
def create
self.current_user = User.authenticate(params[:login],
params[:password])
if logged_in?
session.model.user_id = current_user.id

My problem is that when I log in, the user_id field is not filled in the
sessions table. I have tried many things but I didn’t manage to have it
working.

Could someone give me any idea to fix the problem or to investigate it?

Thanks

John

Try to assign your user_id in application.rb: session.model.user_id =
current_user.id

You should be aware that when a user logout, the associated entry will
be removed from your sessions table. So you won’t keep track of these
users …

Joe

Joe Betsik wrote:

Try to assign your user_id in application.rb: session.model.user_id =
current_user.id

You should be aware that when a user logout, the associated entry will
be removed from your sessions table. So you won’t keep track of these
users …

Joe

Thank you Joe for your response. I tried to move the call in
application.rb but from there it can’t access the model (sesion.model).

In fact I just want to have a log with all users which logs into my
application with the date. I don’t need all other fields stored in the
session and of course I don’t want entries of this log deleted when a
user log out!

I don’t have enough experience with RoR to realize if I’m following a
right path with my sessions stored in a database. I thought I could use
this mechanism to avoid to rewrite a lot of code very similar to that
exist ( I appreciate the DRY concept very much!).

Thanks for any advice,

John