User name in Redmine

╄→гoц情女王★ 提交于 2019-12-10 20:12:10

问题


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:


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?




回答2:


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.



来源:https://stackoverflow.com/questions/3653281/user-name-in-redmine

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!