I’m using declarative roles, a Ryan Bates ‘railscast’ tutorial. I would like to show the role of the user who is logged in, in the view. Is there any variable I can use to display the name of the role?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
As that tutorial goes, a user “has many” roles, but you are not logged in as a particular role at any one time, you have all of them assigned to you, and all of those assigned are valid all at once. They are linked from the user model:
So you could show all the roles with something like
Assuming that current_user is a helper method that gives the current logged in user model instance.