Sha256: 7ea729133ac9b8af620fdffb1eaa74993f90e5768bc44913137636b914896fd9
Contents?: true
Size: 843 Bytes
Versions: 6
Compression:
Stored size: 843 Bytes
Contents
module Adeia module Helpers module UserHelper extend ActiveSupport::Concern module ClassMethods def human_name model_name.i18n_key end end included do extend ClassMethods has_many :permissions, class_name: "Adeia::Permission" end def add_to_group(name) group = Group.find_by_name(name) Adeia::GroupUser.create(group: group, user: self) end def permissions @permissions ||= Adeia::Permission.where(owner: groups << self) end def groups @groups ||= Adeia::Group.joins(:group_users).where(adeia_group_users: { user_id: self.id }) end def belongs_to?(name) Adeia::GroupUser.joins(:group).where(user_id: self.id, adeia_groups: { name: name }).exists? end end end end
Version data entries
6 entries across 6 versions & 1 rubygems