Actions with no views?


#1

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


#2

On 12/27/05, Xavier N. removed_email_address@domain.invalid 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.


#3

On 12/27/05, Xavier N. removed_email_address@domain.invalid 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?

– 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).


rick
http://techno-weenie.net