Between Content and Article and Content and Video? Something like Content belongs_to content_owner? Probably this is also a solution, anyway this is not the point.
Now, i agree this example is really poor, try to figure out a situation were STI fits better if you like but, rather to debate if STI is a good thing or not.. focus instead on the fact that there are things we can't just say with plain migrations alone. Another idea you've just inspired: what about this? class Content inheritable :strategy => :mti field :title class Article field :text now running rails g migration create_articles --from Article will generate the necessary migration to do what you just said but without distorting the *logical* structure: an Article is a Content, and a Video is a Content too. What you would do with association is to say 'Article' has fields of a contents and Video has fields of a content as well. But this is database centric and this is just the kind of coupling that causes pain in the long run. This is another clue that we need a level of abstraction here. >> there is a very important information here: text is something that belongs >> to Article, and url is something that belongs to Video. > > Shouldn't you be using a polymorphic association for those > type-specific fields then, rather than STI? > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Core" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/rubyonrails-core?hl=en. > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
