Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 16th, 2012  |  syntax: None  |  size: 0.47 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. me             = Person.create(:name => 'Harold', :cool_dude => true)
  2. another_harold = Person.create(:name => 'Harold')
  3. someone_else   = Person.create(:name => 'Jack',   :cool_dude => true
  4.  
  5. Person.where(:name => 'Harold')
  6. Person.where(:cool_dude => true)
  7. Person.where(:name => 'Harold').where(:cool_dude => true)
  8.  
  9. class Person
  10.   def self.cool_dudes
  11.     where(:cool_dude => true)
  12.   end
  13.   def self.harolds
  14.     where(:name => 'Harold')
  15.   end
  16. end
  17.  
  18. Person.cool_dudes.harolds