Hi
(Based on the CART exercise in the AWDWR book by the Pragmatic guys.)
I apologize in advance for being long winded, I just wanted to be
thorough since this is kinda still new to me.
In a nutshell, when I click my Empty Cart button which should launch an
AJAX call to the back end ‘blind_up’ my cart, it doesn’t. But if I
refresh the whole page AFTER hitting “Empty Cart” the cart isn’t
displayed. So I surmise that the empty_cart action in my controller IS
being executed but my .rjs template isn’t being handled properly.
Here’s the gory details…
I have a ‘layout’ page in (app/views/layout/store.rhtml) calling a
partial like this:
the _cart.rhtml in (app/view/store) partial looks like this (Calling
another cart_item partial) contains a form_remote_tag to empty my cart.
The app/controllers/store_controller.rb has the empty_cart method as
follows…
def empty_cart
session[:cart] = nil
redirect_to_index
end
private
def redirect_to_index( msg = nil )
flash[:notice] = msg if msg
redirect_to :action => :index
end
AND to ‘dust it all off’ I have an app/views/store/empty_cart.rjs file
that should be ‘executed’ when the empty_cart action is hit.
page[:cart].visual_effect :blind_up
What the heck did I do wrong?