Archive for June 20th, 2008

calling named_scope in a loop doesn’t seem to work in rails 2.1.0 ?

#  # Raises NoMethodError: undefined method `processing'
#  %(pending processing complete error).each do |s|
#    named_scope s.to_sym,
#      :conditions => ["state = ?", s],
#      :order => "priority, created_at"
#  end

named_scope :pending,
:conditions => "state = 'pending'",
:order => "priority, created_at"

named_scope :processing,
:conditions => "state = 'processing'",
:order => "priority, created_at"

named_scope :complete,
:conditions => "state = 'complete'",
:order => "priority, created_at"

named_scope :errorneous,
:conditions => "state = 'error'",
:order => "priority, created_at"