Hi there
I’ve also made a start on the Agile Web Dev using Rails book! I’ve been
hit with a problem when hitting the ‘Add to Cart’ button - I get the
following error message:
ActiveRecord::RecordNotFound in StoreController#add_to_cart
Couldn’t find Product without an ID
RAILS_ROOT: ./script/…/config/…
Application Trace | Framework Trace | Full Trace
D:/Ruby/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:939:in
find_from_ids' D:/Ruby/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:382:in
find’
#{RAILS_ROOT}/app/controllers/store_controller.rb:11:in `add_to_cart’
It seems to me that the id of the item is not been passed in - my
storecontroller code looks like this:
add a product to the cart
def add_to_cart
@cart = find_cart
@product = Product.find(params[:id])
@cart.add_product(@product)
end
It’s not obvious to me where the id is supposed to be set / got from?
Can anybody help?
Thanks,
Dave