... | ... | @@ -28,6 +28,24 @@ create_table "activity_posts", inherits: :activities do |t| |
|
|
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
|
|
|
|
|
|
#### Single record
|
... | ... | |