X-Git-Url: https://git.njae.me.uk/?a=blobdiff_plain;f=app%2Fcontrollers%2Fstore_controller.rb;h=3b2e6b8d2284fb79abea10c62d764d4f9ad573ce;hb=f9d45398338f9e5b2dabd768fcd793c4f81934f2;hp=8234cdcb244d053025bcc790324fc63b1b74352e;hpb=aff195f08c5fc2b8db74058b34720164148cfb4e;p=depot.git diff --git a/app/controllers/store_controller.rb b/app/controllers/store_controller.rb index 8234cdc..3b2e6b8 100644 --- a/app/controllers/store_controller.rb +++ b/app/controllers/store_controller.rb @@ -9,7 +9,8 @@ class StoreController < ApplicationController @cart = find_cart @current_item = @cart.add_product(product) respond_to do |format| - format.js + format.js if request.xhr? + format.html {redirect_to_index} end rescue ActiveRecord::RecordNotFound logger.error("Attempt to access invalid product #{params[:id]}" ) @@ -18,7 +19,7 @@ class StoreController < ApplicationController def empty_cart session[:cart] = nil - redirect_to_index('Your cart has been emptied') + redirect_to_index unless request.xhr? end private