Dan
2006-Dec-23 23:48 UTC
CRUD when saving aggregate objects/calling one controller from another
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 Thanks, Dan --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Pat Maddox
2006-Dec-23 23:55 UTC
Re: CRUD when saving aggregate objects/calling one controller from another
On 12/23/06, Dan <danmunk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Dan
2006-Dec-24 00:11 UTC
Re: CRUD when saving aggregate objects/calling one controller from another
> > There are a number of business related actions required whensaving B> > that do not seem appropriate for the modelHow do you figure? The model is precisely where business-related > actions should go. > > PatI 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? Thanks. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Pat Maddox
2006-Dec-24 01:29 UTC
Re: CRUD when saving aggregate objects/calling one controller from another
On 12/23/06, Dan <danmunk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > > 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?Wrong approach with MVC. Business logic goes in the model. The controller is just for coordinating stuff. Jamis Buck has a good article [1] that ought to shed some light for you. Pat [1] http://weblog.jamisbuck.org/2006/10/18/skinny-controller-fat-model --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Dan
2006-Dec-24 02:02 UTC
Re: CRUD when saving aggregate objects/calling one controller from another
Thanks, the link was very helpful.l --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---