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

Version Path
my_admin-0.1.13 app/model/my_admin/permission.rb
my_admin-0.1.12 app/model/my_admin/permission.rb
my_admin-0.1.11 app/model/my_admin/permission.rb
my_admin-0.1.10 app/model/my_admin/permission.rb
my_admin-0.1.9 app/model/my_admin/permission.rb
my_admin-0.1.8 app/model/my_admin/permission.rb
my_admin-0.1.7 app/model/my_admin/permission.rb
my_admin-0.1.6 app/model/my_admin/permission.rb
my_admin-0.1.5 app/model/my_admin/permission.rb
my_admin-0.1.4 app/model/my_admin/permission.rb
my_admin-0.1.3 app/model/my_admin/permission.rb
my_admin-0.1.2 app/model/my_admin/permission.rb
my_admin-0.1.1 app/model/my_admin/permission.rb
my_admin-0.0.12 app/model/my_admin/permission.rb
my_admin-0.0.11 app/model/my_admin/permission.rb
my_admin-0.0.10 app/model/my_admin/permission.rb
my_admin-0.0.9 app/model/my_admin/permission.rb