# Help with Shopping Cart example from Agile Web Development 2

**URL:** <https://www.ruby-forum.com/t/help-with-shopping-cart-example-from-agile-web-development-2/61971>\
**Category:** Rails\
**Created:** [May 30, 2006, 1:42pm UTC](https://www.ruby-forum.com/t/help-with-shopping-cart-example-from-agile-web-development-2/61971 "2006-05-30T13:42:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aneesha\_Bakharia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f07891/32.png) [@Aneesha\_Bakharia](https://www.ruby-forum.com/u/Aneesha_Bakharia)\
**Post date:** [May 30, 2006, 1:42pm UTC](https://www.ruby-forum.com/t/help-with-shopping-cart-example-from-agile-web-development-2/61971/1 "2006-05-30T13:42:06Z")

</div>

Hi

I get to about page 103 of the book and get an application error.  
Further  
investigation reveals the following error in the dev log:  
Mysql::Error: #42S22Unknown column ‘id’ in ‘where clause’: UPDATE  
sessions  
SET `data` =  
‘BAh7BzoJY2FydG86CUNhcnQGOgtAaXRlbXNbBm86DUNhcnRJdGVtBzoOQHF1\nYW50aXR5aQY6DUBwcm9kdWN0bzoMUHJvZHVjdAY6EEBhdHRyaWJ1dGVzewsi\nDmltYWdlX3VybCIWL2ltYWdlcy9yYWlscy5wbmciCnRpdGxlIgdzZCIKcHJp\nY2UiCjIyLjk1IhNkYXRlX2F2YWlsYWJsZSIYMjAwNi0wMS0wNiAxNjoxNzow\nMCIHaWQiBjEiEGRlc2NyaXB0aW9uIghzZGYiCmZsYXNoSUM6J0FjdGlvbkNv\nbnRyb2xsZXI6OkZsYXNoOjpGbGFzaEhhc2h7AAY6CkB1c2VkewA=\n’,  
`session_id` = ‘8766ece0645091e5e6769c2abf77c5c7’, `updated_at` =  
‘2006-05-30 21:29:38’ WHERE id = NULL

If I delete the session entry from the database, the product listing is  
displayed, but if I reload the page I get the error again. Any help will  
be  
very much appreciated.

---

<div class="post-metadata">

**Author:** ![Aneesha\_Bakharia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f07891/32.png) [@Aneesha\_Bakharia](https://www.ruby-forum.com/u/Aneesha_Bakharia)\
**Post date:** [May 30, 2006, 1:48pm UTC](https://www.ruby-forum.com/t/help-with-shopping-cart-example-from-agile-web-development-2/61971/2 "2006-05-30T13:48:26Z")

</div>

Hmm… the error says that the ‘id’ column can’t be found - that should  
have been created when the sessions table was set up.

Have you checked the ‘sessions’ table in the database to see if it has  
an ‘id’ column?

Steve

---

<div class="post-metadata">

**Author:** ![Aneesha\_Bakharia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f07891/32.png) [@Aneesha\_Bakharia](https://www.ruby-forum.com/u/Aneesha_Bakharia)\
**Post date:** [May 30, 2006, 2:06pm UTC](https://www.ruby-forum.com/t/help-with-shopping-cart-example-from-agile-web-development-2/61971/3 "2006-05-30T14:06:42Z")

</div>

Did you get any errors when you run the rake task? I’m not sure why it  
wouldn’t work…

Just as a note, the ‘id’ doesn’t appear in the migrations because it’s a  
given convention - you wont have to specify it when creating tables  
using migrations.

Steve

---

<div class="post-metadata">

**Author:** ![Aneesha\_Bakharia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f07891/32.png) [@Aneesha\_Bakharia](https://www.ruby-forum.com/u/Aneesha_Bakharia)\
**Post date:** [May 30, 2006, 2:00pm UTC](https://www.ruby-forum.com/t/help-with-shopping-cart-example-from-agile-web-development-2/61971/4 "2006-05-30T14:00:34Z")

</div>

I had trouble running the rake task eg rake db:sessions:create.  
The task runs but the table does not get created. So I just went and  
created  
the database with the three columns from the migration that was  
generated eg

```
  t.column :session_id, :string
  t.column :data, :text
  t.column :updated_at, :datetime

```

I’ve added an id field and the shopping cart is working. Any idea why  
the  
rake task did not create the table.

Thanks for you help.

Aneesha

---

<div class="post-metadata">

**Author:** ![Aneesha\_Bakharia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f07891/32.png) [@Aneesha\_Bakharia](https://www.ruby-forum.com/u/Aneesha_Bakharia)\
**Post date:** [May 30, 2006, 2:28pm UTC](https://www.ruby-forum.com/t/help-with-shopping-cart-example-from-agile-web-development-2/61971/5 "2006-05-30T14:28:47Z")

</div>

Aneesha Bakharia wrote:

> I had trouble running the rake task eg rake db:sessions:create.  
> The task runs but the table does not get created. So I just went and

Are you sure you are rake-ing db:sessions:create and not  
db:session:create? I wrote a post about this on my blog[1], and it is my  
third most popular post so far - it seems lot of people are running into  
this…

bw,  
Peter

[1][http://www.rubyrailways.com/dbsessioncreate-problem-in-the-depot-app/](http://www.rubyrailways.com/dbsessioncreate-problem-in-the-depot-app/)
