Jump to content

The ultimate community for Ruby on Rails developers.


Opinion needed on model(s) structure for content managing model

  • Please log in to reply
1 reply to this topic

#1 Sajonara



  • Members
  • 1 posts

Posted 26 August 2014 - 01:55 AM



I'd like to prepare an app managing content types at the admin side and showing them in the web at the user site, similar to a cms. Now I am not sure what's the most efficient and as well robust way to do so.


I have several ideas concerning the model(s) and it would be very nice if you could comment on them, because my knowledge on this things is scarce yet.


1) Create an articles model consisting of all possible fields the different article types (news, interviews, reviews etc.) could have, like headline, content, etc. I thought of booleans to mark the type of the article.


2) Create an articles model and several models for the different text types and set relations with belongs_to.


3) Create several models for the different article types and only share their content with a common self made controller and another model (in the future, maybe with a polymorphic association).


4) Follow a STI approach.


If I'm mistaken in any of these ideas, please correct me. I'm new to Rails. I only started learning and actively using it some one and a half months ago. In this time I read a lot, did some first steps at Codecademy and also have I been watching different screencasts like those Rails for Zombies.


Kind regards.

#2 Ohm



  • Moderators
  • 398 posts
  • LocationCopenhagen

Posted 26 August 2014 - 05:57 AM

I personally am not fond of the STI approach. There is a reason why the two types are not one. Why should they live in the database as one?


Then again, if they are similar in every way but the name, STI is the way to go, just be aware that using STI makes it harder to expand on. You lose flexibility. 

Blog: http://ohm.sh | Twitter: @madsohm

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users