My project has a number of objects that aggregate other objects. In
certain contexts, objects can either be a root object or a child to
another object.
For example:
Object A can be manipulated on it’s own and has it’s own controller.
Object B can be manipulated on it’s own and has it’s own controller.
Object C can be manipulated on it’s own and has it’s own controller.
Object A has many B instances. C can have many instances of B as well.
What is the best way to reuse the save/update code from controller B
when saving A with B as A’s children?
There are a number of business related actions required when saving B
that do not seem appropriate for the model
they are saved. In otherwords lots of logic. I am pretty new to
Rails, but with other MVC platforms I have tried to put most of the
this type of functionality into controllers. Wrong application with
Rails?
Wrong approach with MVC. Business logic goes in the model. The
controller is just for coordinating stuff. Jamis B. has a good
article [1] that ought to shed some light for you.
There are a number of business related actions required when
saving B
that do not seem appropriate for the modelHow do you figure? The model is precisely where business-related
actions should go.
Pat
I am creating user tasks, sending notifications, starting long-running
business processes, auditing, etc based on the state of the objects as
they are saved. In otherwords lots of logic. I am pretty new to
Rails, but with other MVC platforms I have tried to put most of the
this type of functionality into controllers. Wrong application with
Rails?