rails single table inheritance

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:

  1. You have a type column, of type String in your base model table
  2. You inherit your models from your base model
  3. Each specific model does the validations it needs

An example can be found here.


0 Responses to “rails single table inheritance”

  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Blog Stats

  • 235,816 hits

%d bloggers like this: