Created
February 1, 2011 18:03
-
-
Save rramsden/806280 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create_table "parents", :force => true do |t| | |
t.column "name", :string | |
t.column "type", :string | |
end | |
### | |
class Parent < ActiveRecord::Base | |
end | |
class Child < Parent | |
end | |
class SubChild < Child | |
end | |
#### | |
ruby-1.8.7-p302 > Child.all.size | |
=> 16 | |
DEBUG Child Load (0.6ms) SELECT * FROM `parents` WHERE ( (`parents`.`type` = 'Child' ) ) | |
ruby-1.8.7-p302 > SubChild.all | |
=> [#<SubChild>] | |
DEBUG SubChild Columns (72.4ms) SHOW FIELDS FROM `parents` | |
DEBUG SubChild Load (3.9ms) SELECT * FROM `parents` WHERE ( (`parents`.`type` = 'SubChild' ) ) | |
ruby-1.8.7-p302 > Child.all.size | |
=> 17 | |
^[4DEBUG Child Load (0.9ms) SELECT * FROM `parents` WHERE ( (`parents`.`type` = 'Child' OR `parents`.`type` = 'SubChild' ) ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment