views:

37

answers:

1

I want to have these models:

AbstractArticle 
Article < AbstractArticle
FeaturedArticle < AbstractArticle

I want the name of the database table to be articles and not abstract_articles. (As the convention suggests)

Is this possible with Rails? How can I tell my base model to use a different table? Will STI still work even though the table name does not follow the convention?

+2  A: 

Yes, you can.

class AbstractArticle <  ActiveRecord::Base
  set_table_name :articles
end

http://wiki.rubyonrails.org/rails/pages/howtouselegacyschemas#using_set_table_name_for_table_names_outside_the_rails_convention

Vlad Zloteanu
Wow, Rails never ceases to amaze me. But sometimes it's hard to find stuff...
DR