Topic: Get ID of User (Using LoginGenerator)
I am new in this forum and want to great for fist all of you.
I stated programming Rails applications some days ago and created a app with a restricted user area. For this I used the LoginGenerator.
Everything works perfect. But I have now a table where I want to write data and this table should contain the id of the user who is logged in.
users (id, login, passwd) has_many ads (id, user_id, ...)
I am looking now for a way to get the user_id into these table.
I want to use a before_create in the model ad to fill up the colum ads.user_id with the data of the current connect user.
At moment I have no Idea how to realize this. From the session I got the connected user (users.login) but how can I come to the users.id?
Many thanks for your support