Topic: Content controller
I've been asked to create a fairly simple website for someone in which they'd be able to edit the content themselves (without any knowledge of HTML or coding in general.) The pages have to be hierarchical (one page belongs_to another) and the navigation menu has to be dynamic, adjusting itself to the pages the user creates.
In itself this is simple, I created a table called pages with columns id (int), content (text), parent (int). In the navigation menu I just read all the pages with parent == 0 first and work my way down recursively.
Now my question: my friend asked me to add another feature to the site which would require a completely seperate controller but he still wants to be able to add it to (and move it around) the navigation himself. Also he wants menu items to be able to link to external urls.
What I did was create a special case in the Pages model where, if the content column starts with a ! it takes the word following it to be the name of the controller to link to, otherwise it simply links to the PageController and displays the content. Similarly if the content starts with a # it's assumed to be a link to an external url.
Somehow this solution feels wrong, my gut feeling is I should be doing something with polymorphic associations or some such.. Any thoughts would be much appreciated
* Multiple child models in a dynamic form