# Agile Web Dev on Rails - ActiveRecord::RecordNotFound Prob

**URL:** <https://www.ruby-forum.com/t/agile-web-dev-on-rails-activerecord-recordnotfound-prob/96893>\
**Category:** Rails\
**Created:** [July 3, 2006, 7:38am UTC](https://www.ruby-forum.com/t/agile-web-dev-on-rails-activerecord-recordnotfound-prob/96893 "2006-07-03T07:38:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![davet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/958977/32.png) [@davet](https://www.ruby-forum.com/u/davet)\
**Post date:** [July 3, 2006, 7:38am UTC](https://www.ruby-forum.com/t/agile-web-dev-on-rails-activerecord-recordnotfound-prob/96893/1 "2006-07-03T07:38:17Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![davet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/958977/32.png) [@davet](https://www.ruby-forum.com/u/davet)\
**Post date:** [July 3, 2006, 7:46am UTC](https://www.ruby-forum.com/t/agile-web-dev-on-rails-activerecord-recordnotfound-prob/96893/2 "2006-07-03T07:46:24Z")

</div>

davet wrote:

> It’s not obvious to me where the id is supposed to be set / got from?  
> Can anybody help?

Oops!! Found it!! The button code in my index.rhtml page was missing ‘,  
:id =\> product %\>’…

Anyways, thanks for the help!! 🙂

---

<div class="post-metadata">

**Author:** ![davet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/958977/32.png) [@davet](https://www.ruby-forum.com/u/davet)\
**Post date:** [July 3, 2006, 6:39pm UTC](https://www.ruby-forum.com/t/agile-web-dev-on-rails-activerecord-recordnotfound-prob/96893/3 "2006-07-03T18:39:05Z")

</div>

davet wrote:

> Application Trace | Framework Trace | Full Trace  
> def add\_to\_cart  
> Thanks,  
> Dave

Dave,

Does your app/views/store/index.html file have the “:id =\> product” as  
mentioned in the book? (Pg 113 of the PDF)

Cheers  
Mohit.
