I’ve been struggling a little with single table inheritance in Rails. I think I got the concept. You have one big table which has all the attributes all of your models will need. Based on the validations of each model, you’ll end up having all the correct data for every model you have.
Make sure:
- You have a type column, of type String in your base model table
- You inherit your models from your base model
- Each specific model does the validations it needs
An example can be found here.
Advertisements
0 Responses to “rails single table inheritance”