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?
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.
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
I 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).