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

Sawant:

Yes, it does, with the following code:


  def remove_from_cart
#...
      if request.xhr?
          respond_to { |format| format.js }
      else
        redirect_to_index
    end
#...
  end
h4. Jack47: @Jinyoung and @Sawant: I think we don’t need “if request.xhr? “in respond_to, you can see request_to()http://apidock.com/rails/ActionController/MimeResponds/respond_to. If the browser has JavaScript disabled, then the XHR request is also disabled. I think in this situation, “if request.xhr?” is meaningless.