Current user's id?

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

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

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

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