Guest User

Untitled

a guest
Feb 19th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. class StarWarsCharacters < ActiveRecord::Base
  2. named_scope :born_on_tatooine, :conditions => ["birthplace LIKE ?", "Tatooine"]
  3. end
  4.  
  5. class Jedi < StarWarsCharacters
  6. end
  7.  
  8. class Sith < StarWarsCharacters
  9. end
  10.  
  11. > Sith.create :name => "Darth Vader", :birthplace => "Tatooine"
  12. > reload!
  13. > Jedi.born_on_tatooine
  14. => []
  15. > Sith.born_on_tatooine
  16. => #<Sith id: 1, name: "Darth Vader", type: "Sith">]
  17.  
  18. Good!
  19.  
  20. > Jedi.born_on_tatooine
  21. => #<Sith id: 1, name: "Darth Vader", type: "Sith">]
  22.  
  23. ?????
Add Comment
Please, Sign In to add comment