def current_active_role
user_roles.each do |r|
if r.is_active_role
return r
end
end
return nil
end
The block above returns whatever the user's currently active role is. There are User, UserRoles (lookup table), and Roles tables.
I'm looking for a more concise way to say "go through all their individual roles, find the active one and return it, or implicitly return nil if none of them are the active role."