I am working on a project where we offer a very simple homespun CMS type backend. It allows you to edit/delete various attributes on the Page model.
There are a reasonably large amount of editable fields similar to any other CMS. We want to split these up into 3 logical section to make it easier for our customers.
We want to have a page for editing the Page content then we want a page for uploading/changing the Page image and then we want a page to upload metadata for the Page.
Currently I have a PageController and all three sections are just updating the Page model however the question is how do I best use Rails controllers to do this in a way that obvious to other Rails developers?
Do I just have 3 methods on the Page controller, one for content, one for image and one for metadata?
OR
Do I create a new Controller called something like CMSController and have 3 methods on this and then just keep my PageController to do the usual RESTful heavylifting such as actually saving and creating new Pages?
Thanks for your help.
It’s a good idea to have a
CmsControllerorPublicControllerfor handling yourroot_pathany actions you want taken care of there.Do read up on Member and Collection routes; you can have as many of these under
PagesControllerto achieve exactly what you want. Just make sure those methods are private so that they are not publicly accessible — this would be a moot point though if your admin is namespaced and hardened accordingly. You can see an example of a namespaced admin in one of my projects.