Forum: Ruby on Rails actions with no views?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
7223c62b7310e164eb79c740188abbda?d=identicon&s=25 Xavier Noria (Guest)
on 2005-12-27 22:40
(Received via mailing list)
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
119af50160cabfe1fb6f2f05f5018c64?d=identicon&s=25 James Ludlow (Guest)
on 2005-12-27 22:46
(Received via mailing list)
On 12/27/05, Xavier Noria <fxn@hashref.com> 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.
821395fe70906c8290df7f18ac4ac6cf?d=identicon&s=25 Rick Olson (Guest)
on 2005-12-27 23:04
(Received via mailing list)
On 12/27/05, Xavier Noria <fxn@hashref.com> 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
This topic is locked and can not be replied to.