projects
/
depot.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Finished chapter 9
[depot.git]
/
app
/
controllers
/
store_controller.rb
diff --git
a/app/controllers/store_controller.rb
b/app/controllers/store_controller.rb
index 8234cdcb244d053025bcc790324fc63b1b74352e..3b2e6b8d2284fb79abea10c62d764d4f9ad573ce 100644
(file)
--- 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|
@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]}" )
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
def empty_cart
session[:cart] = nil
- redirect_to_index
('Your cart has been emptied')
+ redirect_to_index
unless request.xhr?
end
private
end
private