Task D: A Dash Of Ajax #2
Nicolas:
-Yes :-)-
James:
No. I found that StoreController.redirect_to_index method would complain. Here's what we had before:
def redirect_to_index(msg) flash[:notice] = msg if msg redirect_to :action => :index end
Rails would complain "wrong number of arguments (0 for 1)". You can resolve this by setting the default value of the msg variable to nil as follows:
def redirect_to_index(msg=nil) flash[:notice] = msg if msg redirect_to :action => :index end
(Sidebar: if you're developing web applications for the first time, a handy Firefox extension you should use is the Web Developer Toolbar (https://addons.mozilla.org/firefox/60/). This handy toolbar allows you to easily test your Ajax-less experience at the click of a button.)
Marcello:
You should already have altered the method on the creation of the AJAX cart. Also, don't forget to use the statement modifier unless request.xhr? to handle the downgrade.
Jinyoung:
I've done like below:
def empty_cart session[:cart] = nil respond_to do |format| format.js if request.xhr? format.html {redirect_to_index} end end
page revision: 1, last edited: 13 Oct 2008 15:25