hi, I''ve to check something like: the user can have the same object in the wish list only once. example: the user put the object X in the wish list - ok the user try to add the object X to the wish list another time --> not ok, the user is redirected to another url with a notice because i use the session and notice i think i''ve to put the control in the controller(because the model doesn''t know anything about session, redirect and notice), but i should put it also in the model? usually what kind of controls i''ve to write in the controller and when in the model? thanks -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Philip Hallstrom
2007-Feb-04 00:44 UTC
Re: where i should put it ? controller, model or both?
> hi, I''ve to check something like: the user can have the same object in > the wish list only once. > example: > the user put the object X in the wish list - ok > the user try to add the object X to the wish list another time --> not > ok, the user is redirected to another url with a notice > because i use the session and notice i think i''ve to put the control in > the controller(because the model doesn''t know anything about session, > redirect and notice), but i should put it also in the model? > usually what kind of controls i''ve to write in the controller and when > in the model? > thanksIf your business logic mandates that the wish list has to have a unique list of items, then that should go in your model so that regardless of where you manage the wish list the rules hold up. If it''s not mandated, but only in this one instance, then put the check in the controller. Me, I''d put it in the model, and return an error if it''s duplicated that your controller can use to redirect somewhere else. -philip --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---