In Depot, the demo application in the the Agile book, actions that modify the model such as add_to_cart redirect to another action that has a clear view role, like index, or show_cart, instead of generating the view themselves. This uses an HTTP redirect that goes to the client and returns. Is this an idiomatic way to design the flow in Rails? -- fxn
On 12/27/05, Xavier Noria <fxn-xlncskNFVEJBDgjK7y7TUQ@public.gmane.org> wrote:> In Depot, the demo application in the the Agile book, actions that > modify the model such as add_to_cart redirect to another action that > has a clear view role, like index, or show_cart, instead of > generating the view themselves. This uses an HTTP redirect that goes > to the client and returns. > > Is this an idiomatic way to design the flow in Rails?I don''t have the book in front of me, but I think that one of the reasons they did this was so that the browser wouldn''t try to add the same item to the cart if the user hit refresh.
On 12/27/05, Xavier Noria <fxn-xlncskNFVEJBDgjK7y7TUQ@public.gmane.org> wrote:> In Depot, the demo application in the the Agile book, actions that > modify the model such as add_to_cart redirect to another action that > has a clear view role, like index, or show_cart, instead of > generating the view themselves. This uses an HTTP redirect that goes > to the client and returns. > > Is this an idiomatic way to design the flow in Rails? > > -- fxnI suppose that''s the way David writes his apps, so naturally it''s how Rails scaffolding works. You can of course do whatever you wish. These days those actions now have rjs templates for ajax calls and the redirect for normal http calls (in my own apps anyway, YMMV). -- rick http://techno-weenie.net