Project

General

Profile

Download (714 Bytes) Statistics
| Branch: | Tag: | Revision:
acfbc458 Marek Hulan
class Permission < ActiveRecord::Base
attr_accessible :name, :resource_type

3034e8e2 Ori Rabin
validates_lengths_from_database
04ad52f7 Joseph Magen
validates :name, :presence => true, :uniqueness => true
acfbc458 Marek Hulan
has_many :filterings, :dependent => :destroy
has_many :filters, :through => :filterings

2dec184c Eric D. Helms
scoped_search :on => :name, :complete_value => true
scoped_search :on => :resource_type

acfbc458 Marek Hulan
def self.resources
@all_resources ||= Permission.uniq.order(:resource_type).pluck(:resource_type).compact
end

def self.resources_with_translations
with_translations.sort { |a, b| a.first <=> b.first }
end

def self.with_translations
resources.map { |r| [_(Filter.get_resource_class(r).try(:humanize_class_name) || r), r] }
end
end