Reputation: 48453
I have following models:
has_many :roles, :through => :assignments
has_many :assignments
has_many :users, :through => :assignments
belongs_to :user belongs_to :role
Whole evening I am trying to find a way, how to print somewhere, what kind of role has currently log in user. I tried already stuffs like
@log_in_user.roles.type_of_role
or
@log_in_user.assignments.type_of_role
but unfortunately nothing succes... Could anyone give me any idea how get this information?
Thanks a lot!
Upvotes: 0
Views: 37
Reputation: 107728
Use this:
@log_in_user.roles.map(&:type_of_role)
That will return an array of the type_of_role
attribute for each role the user has.
Upvotes: 1