comparison app/models/enumeration.rb @ 514:7eba09d624db live

Merge
author Chris Cannam
date Thu, 14 Jul 2011 10:50:53 +0100
parents 0c939c159af4
children cbb26bc654de
comparison
equal deleted inserted replaced
512:b9aebdd7dd40 514:7eba09d624db
30 validates_uniqueness_of :name, :scope => [:type, :project_id] 30 validates_uniqueness_of :name, :scope => [:type, :project_id]
31 validates_length_of :name, :maximum => 30 31 validates_length_of :name, :maximum => 30
32 32
33 named_scope :shared, :conditions => { :project_id => nil } 33 named_scope :shared, :conditions => { :project_id => nil }
34 named_scope :active, :conditions => { :active => true } 34 named_scope :active, :conditions => { :active => true }
35 named_scope :named, lambda {|arg| { :conditions => ["LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip]}}
35 36
36 def self.default 37 def self.default
37 # Creates a fake default scope so Enumeration.default will check 38 # Creates a fake default scope so Enumeration.default will check
38 # it's type. STI subclasses will automatically add their own 39 # it's type. STI subclasses will automatically add their own
39 # types to the finder. 40 # types to the finder.