views:

35

answers:

2

I want to get current user's name. As documentation describes, I should user User.name method. Tried to use it as in the example - didn't work. Tried this:

val = User.current.name

And this:

user = User.find(User.current.id)
val = user.name


What am I doing wrong?

+1  A: 

Unless you do something strange with your Redmine instance, you should always have a User.current. So you should also be able to use User.current.name.

As this did not work, as you said, could you please elaborate a bit on what exactly didn't work?

Holger Just
Even when not logged in, User.current is the anonymous user which returns "Anonymous" for User.current.name
Reuben Mallaby
A: 

You need a session or a cookie with a current user assigned (see the application controller) so you cant just console in and ask for the current user.

Jed Schneider