Skip to content

Instantly share code, notes, and snippets.

@Mikr0Tik
Created March 29, 2010 08:36
Show Gist options
  • Save Mikr0Tik/347606 to your computer and use it in GitHub Desktop.
Save Mikr0Tik/347606 to your computer and use it in GitHub Desktop.
class Person < ActiveRecord::Base
named_scope :job, lambda { |name|
{ :joins => :job, :conditions => { "job.name" => name } }
}
named_scope :car, lambda { |number|
{ :joins => :car, :conditions => { "car.number" => number } }
}
end
person = Person.job('Task').car(23)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment