I'm following along with the examples in AWDWR (3rd), and around about
p. 103, where you are working with a session table you created, I
decided to free lance a bit. At some point, I tried to "clear" the
session by doing the following:
I figured that would "erase" the old cart, and let me continue with a
new, empty cart. However, everything is completely messed up now, and
when I try to access a "store page" (which lists the products for sale)
using the following url:
We're sorry but something went wrong.
We've been notified about this issue and
we will take a look at it shortly.
As a fix, I tried rolling back the migration that created the session
table:
rake db:rollback
and then doing:
db:migrate
but I get that same error page. So I'm stuck. So much for free
lancing. Is there some obvious way I can get rid of that error page and
get sessions working again.
Alternatively, I have git installed and I committed my changes at the
end of the last chapter(p. 96). But I've read several git tutorials,
and I can't figure out how to rollback to a previous version of my code.
Sorry, I can access the store page. It's when I click a button that
calls an add_to_cart action that I get that error message. This is the
url after I click on the add_to_cart button:
private
def find_cart
session[:cart] ||= Cart.new
end
If I change that method to:
def find_cart
Cart.new
end
then clicking on an "add to cart" button no longer shows me the error
message. I get a view that lists what was added to the cart. However,
without sessions the view just shows the current item that is being
added.
As soon as I add back the line that mentions sessions:
private
def find_cart
session[:cart] ||= Cart.new
end