Alert icon
We're changing our privacy policy. This stuff matters.  Learn more  Dismiss

Single Table Inheritance - Ruby on Rails Tutorial

Loading...

Sign in or sign up now!
Alert icon
Upgrade to the latest Flash Player for improved playback performance. Upgrade now or more info.
1,147
Loading...
Alert icon
Sign in or sign up now!
Alert icon

Uploaded by on Apr 8, 2011

Single Table Inheritance is a terrific way of sharing functionality and database fields between Models. It encapsulates the Inheritance principle of Object Oriented Programming.

If you have a model that could be one type of another model, use STI.

  • likes, 0 dislikes

Link to this comment:

Share to:

Uploader Comments (charlesmaxwood)

  • This system works on convention. I'm not sure there's a way to configure it to take an integer. You can't name classes with just integers anyhow and it expects you to put the class name in there.

    You could skip using STI and put a type column as an integer in. Then your query would have to include "(type = 1)" or something similar.

see all

All Comments (2)

Sign In or Sign Up now to post a comment!
  • What if you wanted to use an int field for the type column? How would you do this?

Loading...

Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more