end
end
- scope :sorted, lambda { order("#{table_name}.position ASC") }
+ scope :sorted, lambda { order(:position) }
scope :visible, lambda {|*args|
user = args.shift || User.current
if user.admin?
validates_length_of :name, :maximum => 30
scope :shared, lambda { where(:project_id => nil) }
- scope :sorted, lambda { order("#{table_name}.position ASC") }
+ scope :sorted, lambda { order(:position) }
scope :active, lambda { where(:active => true) }
scope :system, lambda { where(:project_id => nil) }
scope :named, lambda {|arg| where("LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip)}
before_destroy :remove_references_before_destroy
- scope :sorted, lambda { order("#{table_name}.type, #{table_name}.lastname ASC") }
+ scope :sorted, lambda { order(:type => :asc, :lastname => :desc) }
scope :named, lambda {|arg| where("LOWER(#{table_name}.lastname) = LOWER(?)", arg.to_s.strip)}
scope :givable, lambda {where(:type => 'Group')}
validates_inclusion_of :default_done_ratio, :in => 0..100, :allow_nil => true
attr_protected :id
- scope :sorted, lambda { order("#{table_name}.position ASC") }
+ scope :sorted, lambda { order(:position) }
scope :named, lambda {|arg| where("LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip)}
def update_default
['own', :label_issues_visibility_own]
]
- scope :sorted, lambda { order("#{table_name}.builtin ASC, #{table_name}.position ASC") }
- scope :givable, lambda { order("#{table_name}.position ASC").where(:builtin => 0) }
+ scope :sorted, lambda { order(:builtin, :position) }
+ scope :givable, lambda { order(:position).where(:builtin => 0) }
scope :builtin, lambda { |*args|
compare = (args.first == true ? 'not' : '')
where("#{compare} builtin = 0")
validates_uniqueness_of :name
validates_length_of :name, :maximum => 30
- scope :sorted, lambda { order("#{table_name}.position ASC") }
+ scope :sorted, lambda { order(:position) }
scope :named, lambda {|arg| where("LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip)}
def to_s; name end