I have an article controller, which manages all article relations like authors, translations, related articles and so on in one update action at this moment.
Page contains a bunch of “Listings” with search and sort capabilities,CRD actions, forms for creating new and manage existing association records.
All this stuff is managed by ArticleController edit and update actions and bunch of partial templates for each listing.
I want to extend functionality more by adding additional search tables to find records for association. And later I’ll add some other features.
I feel that this way (all association management in one edit page) is far far from convenient. So, maybe, better is to create some special controllers for each listing like:
/articles/1/edit/authors
And what should be the name of this controller? Should it be children of ArticleController or PeopleController or ApplicationController?
or maybe all okay and I am paranoiac?)
UPD
All MVC conditions are sctictly met. Question is:
Is it good to manage all relations in one controller. Not only add/remove relation, sometimes creating a newone, like @article.authors.find_or_create_by_name(name). Relations in view are not simply select tags! They are fullyfeachured tables with own search, sort, paginate capabilities.
If someone dont understand me, lets ask in different way:
how to create a “subcontroller”: if we have ArticleController and its edit action. ArticleController should manage only fields in Article model. And a bunch of subcontrollers should manage relations.
Why I am need it?
Lets add a AJAX to such page: no serious problems are met, but on every AJAX call ArticleController.update/edit actions a query and thay may do some unnessesary work like building Arel relations for models, that will never be used. I like to divide work into small independent pieces, not to build a one huge Controller, that can do everything.
You article
controllershouldn’t manage relations. That should be in yourmodel. Look into active recordcallbacks. You can do everything related to managing your authors, translations, etc in a callback. For example, in aafter_updatecallbackYou also want to be using
nested resources. For example, yourauthorsare nested inside yourarticles