Hi guys,

Before I explain anything here's my setup:

Mac OS X
Ruby 1.8.7 from source, RubyGems, Rails 2.3.2, MySQL from source, the
ruby mysql adapter gem and mongrel.
Firefox 3.07

I'm new to rails and happily understanding everything as I follow
through the pragmatic programmers depot application tutorial from
their 'agile development with rails v3 p1.0' but one thing has me
completely stumped. I am onto the section where we're storing the cart
items in the session store, specifically this store is the db. Now
when I run rake db:sessions:create & migrate then change the
session_store initializer in the environments folder to use the active
record store things just break! So here's an excerpt from the code:

  def add_to_cart
    product = Product.find(params[:id])
    @cart = find_cart
    @cart.add_product(product)
  end

  private

  def find_cart
    session[:cart] ||= Cart.new
  end

Easy enough it seems however when the action 'add_to_cart' is called I
get a nasty page showing an invalid authenticity token. Here's the
request params: {"authenticity_token"=>"x4KicmZNjfb9c+X6prUPu6XLe8QfjB/
uRN+PR0+TNWc=",
 "id"=>"6"}

So that seems straight forward enough - there is an authenticity token
but it's invalid for some reason. I then tried setting the development
environment variable config.action_controller.allow_forgery_protection
to false which made functionality appear to work, however... when
monitoring the db it seems that every time I click add to cart a new
session is created!! I'm completely stumped because when I revert so
the session store is using the default cookiestore things work great
and the items I expect to appear in my cart until the session data is
greater than 4kb then it breaks again but that's understandable as we
shouldn't be storing objects in the cookie session data so is this
then a problem with this release of rails?

Any help is much appreciated I just want to get rocking with rails now
and this has held me back all day!

Thanks in advance

Kind Regards
Richard Delph
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to