... | @@ -28,6 +28,24 @@ create_table "activity_posts", inherits: :activities do |t| |
... | @@ -28,6 +28,24 @@ create_table "activity_posts", inherits: :activities do |t| |
|
end
|
|
end
|
|
```
|
|
```
|
|
|
|
|
|
|
|
### Models
|
|
|
|
|
|
|
|
In other to have your models working correctly and take fully advantage of this feature, the same way the tables are inherited, the models need to be inherited as well.
|
|
|
|
|
|
|
|
```ruby
|
|
|
|
# models/activity.rb
|
|
|
|
class Activity < ApplicationRecord
|
|
|
|
end
|
|
|
|
|
|
|
|
# models/activity_book.rb
|
|
|
|
class ActivityBook < Activity
|
|
|
|
end
|
|
|
|
|
|
|
|
# models/activity_post.rb
|
|
|
|
class ActivityPost < Activity
|
|
|
|
end
|
|
|
|
```
|
|
|
|
|
|
### Querying
|
|
### Querying
|
|
|
|
|
|
#### Single record
|
|
#### Single record
|
... | | ... | |