Forum: Ruby on Rails current user's id?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Jeremy P. (Guest)
on 2006-05-12 00:22
I'm new to rails and have a question that seems simple but that I cannot
resolve.

Is there a way to find the id of the currently logged in user?

Thanks,
JP
Sean C. (Guest)
on 2006-05-12 05:36
Jeremy P. wrote:
> I'm new to rails and have a question that seems simple but that I cannot
> resolve.
>
> Is there a way to find the id of the currently logged in user?
>
> Thanks,
> JP

Maybe you can store it in the session when they log in. Then it's there
and you can just pull it out whenever you need it. I'm new too.

sean
Iphan I. (Guest)
on 2006-05-12 14:17
sean colquhoun wrote:
> Jeremy P. wrote:
>> I'm new to rails and have a question that seems simple but that I cannot
>> resolve.
>>
>> Is there a way to find the id of the currently logged in user?

not sure I understand with 'logged in user', if you have authentication
enabled, then you get the User object from the username stored in the
session, but if you just want to access the current session id then
perhaps this is what you need:

session.session_id

or look in the rails API for Module ActionController::SessionManagement

regards

Isabelle
Iphan I. (Guest)
on 2006-05-12 14:18
sean colquhoun wrote:
> Jeremy P. wrote:
>> I'm new to rails and have a question that seems simple but that I cannot
>> resolve.
>>
>> Is there a way to find the id of the currently logged in user?

not sure I understand what is meant here with 'logged in user'... if you
have authentication enabled, then you get the User object from the
username stored in the session, but if you just want to access the
current session id then perhaps this is what you need:

session.session_id

maybe have a look in the rails API for Module
ActionController::SessionManagement

regards

Isabelle
This topic is locked and can not be replied to.