Hi there,
I do think this is a simple but when we dont know how, it is not simple
at all.
I have got a shopping cart and URL to show it is something like
…/shop/cart/edit, and in the template cart.rhtml, I have some buttons
to increment, decrement, remove items in the cart, accordingly in the
cart controller, I have a method for each button, for instance,
def increment
…
render :action=>‘edit’
end
It works! However in the browser, the URL is changed from
…/shop/cart/edit to …/shop/cart/increment/[item id]. Then if I click
on refresh button in the browser, the increment action will be redone,
that’s what I want to prevent. What I want exactly is I would like to
see the URL …/shop/cart/edit unchanged after the buttons are clicked.
I know, I can call redirect_to instead of render, but performance would
not be the same. Any idea and hit are greatly appreciated. Thanks!
that’s what I want to prevent. What I want exactly is I would like to
see the URL …/shop/cart/edit unchanged after the buttons are
clicked.
I know, I can call redirect_to instead of render, but performance
would
not be the same. Any idea and hit are greatly appreciated. Thanks!
That’s not possible. If the way the browser gets to it is /shop/cart/
increment/[item id] then that’s the url you’ll get, unless you do a
redirect
An alternative would be to use ajax, which won;t change the url and
won’t result in a refresh repeating the action.
Hi there,
I do think this is a simple but when we dont know how, it is not simple
at all.
I have got a shopping cart and URL to show it is something like
…/shop/cart/edit, and in the template cart.rhtml, I have some buttons
to increment, decrement, remove items in the cart, accordingly in the
cart controller, I have a method for each button, for instance,
def increment
…
render :action=>‘edit’
end
It works! However in the browser, the URL is changed from
…/shop/cart/edit to …/shop/cart/increment/[item id]. Then if I click
on refresh button in the browser, the increment action will be redone,
that’s what I want to prevent. What I want exactly is I would like to
see the URL …/shop/cart/edit unchanged after the buttons are clicked.
I know, I can call redirect_to instead of render, but performance would
not be the same. Any idea and hit are greatly appreciated. Thanks!
Franck
use ajax.
incidentally, i would highly recommend u download (as far as i know the
only one around) the substruct ror commerce code - can learn a lot from
it (code is highly written) as the best way to learn code is to learn
from reading existing projects.
aside from that i’m sure there are parts there u can use in your app
(CTR-c) if u place them in the right spots | modify the code slightly
for u’r specific needs.
either way, it is also a great opportunity to progress into good
programming as well. here:
Fred and Shai,
Thank you very much for your reply!
I agree with you: Ajax is the right solution that I will implement in
the following days.
And thank you again for your help!
Franck
Shai R. wrote:
use ajax.
incidentally, i would highly recommend u download (as far as i know the
only one around) the substruct ror commerce code - can learn a lot from
it (code is highly written) as the best way to learn code is to learn
from reading existing projects.
aside from that i’m sure there are parts there u can use in your app
(CTR-c) if u place them in the right spots | modify the code slightly
for u’r specific needs.
either way, it is also a great opportunity to progress into good
programming as well. here: