Sha256: 84b2709a08b287db3eb8d200b7299e38f13ea1a23b59a77cbbef2f9991204dfe
Contents?: true
Size: 769 Bytes
Versions: 17
Compression:
Stored size: 769 Bytes
Contents
class MyAdmin::Permission < ActiveRecord::Base self.table_name = "my_admin_permissions" has_many :group_permissions, :dependent => :destroy has_many :groups, :through => :group_permissions validates_presence_of :model, :name, :application validates_uniqueness_of :name, :scope => [:model, :name, :application] def to_s application = MyAdmin::Application.find(self.application) application.title + ">" + self.model.constantize.title + " - " + I18n.t("my_admin.permissions.#{self.name}") end scope :by_user, ->(user_id){ joins({:groups => [:users]}).where("my_admin_users.id" => user_id) } # scope :by_user, lambda { |user_id| # { :joins => {:groups => [:users]}, :conditions => {"my_admin_users.id" => user_id} } # } end
Version data entries
17 entries across 17 versions & 1 rubygems