Skip to content

Instantly share code, notes, and snippets.

@dtrasbo
Created May 2, 2010 22:40
Show Gist options
  • Save dtrasbo/387523 to your computer and use it in GitHub Desktop.
Save dtrasbo/387523 to your computer and use it in GitHub Desktop.
class Car < ActiveRecord::Base
named_scope :color, lambda { |color| {:conditions => {:color => color }} }
named_scope :by_age, :order => 'created_at'
end
Car.color('red').by_age # returns all cars where color equals red ordered by age
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment