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.
F185164221b04dadde8423569b12aa4c?d=identicon&s=25 Jeremy Pettet (jpettet)
on 2006-05-11 22: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
241b11f59c4bcfc2ce84a43f52b30001?d=identicon&s=25 Sean Cahoon (osakaboy)
on 2006-05-12 03:36
Jeremy Pettet 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
Cac068c9c92719a59db960b2fa51719c?d=identicon&s=25 Iphan Iphan (iphan)
on 2006-05-12 12:17
sean colquhoun wrote:
> Jeremy Pettet 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
Cac068c9c92719a59db960b2fa51719c?d=identicon&s=25 Iphan Iphan (iphan)
on 2006-05-12 12:18
sean colquhoun wrote:
> Jeremy Pettet 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.