User name in Redmine
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?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?
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.
精彩评论