Forum: Ruby on Rails Help with Shopping Cart example from Agile Web Development 2

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Aneesha Bakharia (Guest)
on 2006-05-30 15:42
(Received via mailing list)
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.
Stephen B. (Guest)
on 2006-05-30 15:48
(Received via mailing list)
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
Aneesha Bakharia (Guest)
on 2006-05-30 16:00
(Received via mailing list)
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
Stephen B. (Guest)
on 2006-05-30 16:06
(Received via mailing list)
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
Peter S. (Guest)
on 2006-05-30 16:28
(Received via mailing list)
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-proble...
This topic is locked and can not be replied to.