Module: Role::Authorized::ClassMethods

Defined in:
app/models/role.rb

Instance Method Summary collapse

Instance Method Details

#role_relation(name, role_name) ⇒ Object


55
56
57
58
59
60
# File 'app/models/role.rb', line 55

def role_relation(name, role_name)
  scope name.to_sym, ->(user) {
    joins(:roles, :users)
      .where(roles: { name: role_name.to_s }, users: { id: user.id })
  }
end