I’ve encountered a perplexing problem whilst following along the demo
app in the “Agile Web D. with Rails” book. Any help would be
greatly appreciated. Here is a brief time line of my tale of woe:-
0. Been programming (business apps) and designing/building DBs for two
decades - but new to both Ruby and Rails (so I apologise in advance if
I’ve made some really elementary mistake)
- Purchased the Agile Web Devt with Rails book
- Been following along with the “Book Depot” sample app - all going
well - Had already figured out (with the help of Google, a Mike C.
article, etc.) that (e.g.) “@version_control_book” used in book didn’t
work - and had changed all references to (e.g.)
“products(:version_control_book)” - Got to “test_checkout” (in “Testing Controllers” on page 158) - then
all hell broke loose. Many, many errors scrolled past too quickly to
see. - Subsequently found that NO tests were working - including ALL the
previous tests which had of course worked just fine before the explosion - Googled “test_checkout” and found at least one coherent article that
recommended “GEMS UPDATE” to solve the problem - Ran “gems update” - seemed to update a number of Rails components and
reported success after 5 - 10 minutes - Unfortunately, ALL tests (including previously working Unit and
Functional tests) now failing uniformly (and with voluminous messages) -
see example below
D:\rails\depot>ruby test/unit/order_test.rb
Loaded suite test/unit/order_test
Started
EE
Finished in 0.109 seconds.
1) Error:
test_truth(OrderTest):
ActiveRecord::StatementInvalid: Mysql::Error: Lost connection to MySQL
server during query: DELETE FROM orders
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/connection_adapters/abstract_adapter.rb:88:in
`log'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/connection_adapters/mysql_adapter.rb:180:in
`execute'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/connection_adapters/mysql_adapter.rb:195:in
`delete'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/fixtures.rb:279:in
`delete_existing_fixtures'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/fixtures.rb:252:in
`create_fixtures'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/fixtures.rb:252:in
`each'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/fixtures.rb:252:in
`create_fixtures'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/fixtures.rb:251:in
`transaction'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/fixtures.rb:251:in
`create_fixtures'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/fixtures.rb:244:in
`silence'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/fixtures.rb:244:in
`create_fixtures'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/fixtures.rb:540:in
`load_fixtures'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/fixtures.rb:487:in
`setup_with_fixtures'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/fixtures.rb:522:in
`setup'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/fixtures.rb:521:in
`setup'
2) Error:
test_truth(OrderTest):
NoMethodError: You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occured while evaluating nil.-
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/transactions.rb:112:in
`unlock_mutex'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/fixtures.rb:509:in
`teardown'
1 tests, 0 assertions, 0 failures, 2 errors
- Worse still, none of the development web pages (e.g. the Store index
at http://localhost:3000/store) work any more. (See example error
message below)
ActiveRecord::StatementInvalid in Store#index
Mysql::Error: Lost connection to MySQL server during query: SELECT *
FROM products WHERE (date_available <= now()) ORDER BY date_available
desc
RAILS_ROOT: ./script/../config/..
Application Trace | Framework Trace | Full Trace
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/connection_adapters/abstract_adapter.rb:88:in
`log'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/connection_adapters/mysql_adapter.rb:180:in
`execute'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/connection_adapters/mysql_adapter.rb:322:in
`select'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/connection_adapters/mysql_adapter.rb:171:in
`select_all'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:431:in
`find_by_sql'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:395:in
`find'
#{RAILS_ROOT}/app/models/product.rb:12:in `salable_items'
#{RAILS_ROOT}/app/controllers/store_controller.rb:6:in `index'
Request
Parameters: None
Show session dump
---
:user_id:
flash: !ruby/hash:ActionController::Flash::FlashHash {}
Response
Headers: {"cookie"=>[], "Cache-Control"=>"no-cache"}
-
No problem with MySQL server or DBs that I can tell - via MySQL Query
Browser v1.1.17 can still browse all the tables and see all the
previously entered users, products, orders, etc. in the DEV DB -
For what its worth - here are the specific versions of the key bits
of software involved
Rails version: 1.0 (now! - after Gems Update - couldn’t swear exactly
what version it was prior to that)
Ruby version: ruby 1.8.2 (2004-12-25) [i386-mswin32]
MySQL version: 5.0.15-nt [Note: all tables created as InnoDB]
Development box: Windows XP Pro (SP2) on Dell Inspiron 9300
If anyone could suggest a way out of my predicament I would be eternally
grateful. Otherwise I guess my next step will be to try the “Microsoft
solution” - delete and then re-install all the key bits of software and
hope the problems magically go away!
Thanks,
Bruce Healy [Bruce DOT Healy AT gmail DOT com]