Skip to content

Instantly share code, notes, and snippets.

@tokumine
Created September 10, 2008 16:42
Show Gist options
  • Save tokumine/9940 to your computer and use it in GitHub Desktop.
Save tokumine/9940 to your computer and use it in GitHub Desktop.
class StarWarsCharacters < ActiveRecord::Base
named_scope :born_on_tatooine, :conditions => ["birthplace LIKE ?", "Tatooine"]
end
class Jedi < StarWarsCharacters
end
class Sith < StarWarsCharacters
end
> Sith.create :name => "Darth Vader", :birthplace => "Tatooine"
> reload!
> Jedi.born_on_tatooine
=> []
> Sith.born_on_tatooine
=> #<Sith id: 1, name: "Darth Vader", type: "Sith">]
Good!
> Jedi.born_on_tatooine
=> #<Sith id: 1, name: "Darth Vader", type: "Sith">]
?????
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment