NoMethodError: undefined method `key?' for "product :ruby cart :one":String

Hi,
I am going through the Agile web development with rails 4th edition
and am getting this error. It seems to be related to the fixtures (my
guess) and all the tests are failing. Can someone point me in the
right direction to understand what I did wrong here? Here is the
first failure in the test:unit (they all fail)

  1. Error:
    test_the_truth(CartTest):
    NoMethodError: undefined method key?' for "product :ruby cart :one":String /Users/akkdio/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.0.7/ lib/active_record/fixtures.rb:589:inblock (2 levels) in
    insert_fixtures’
    /Users/akkdio/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.0.7/
    lib/active_record/fixtures.rb:588:in each' /Users/akkdio/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.0.7/ lib/active_record/fixtures.rb:588:inblock in insert_fixtures’
    /Users/akkdio/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.0.7/
    lib/active_record/fixtures.rb:582:in each' /Users/akkdio/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.0.7/ lib/active_record/fixtures.rb:582:ininsert_fixtures’
    /Users/akkdio/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.0.7/
    lib/active_record/fixtures.rb:526:in block (4 levels) in create_fixtures' /Users/akkdio/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.0.7/ lib/active_record/fixtures.rb:526:ineach’
    /Users/akkdio/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.0.7/
    lib/active_record/fixtures.rb:526:in block (3 levels) in create_fixtures' /Users/akkdio/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.0.7/ lib/active_record/connection_adapters/abstract/database_statements.rb: 139:intransaction’
    /Users/akkdio/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.0.7/
    lib/active_record/fixtures.rb:524:in block (2 levels) in create_fixtures' /Users/akkdio/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.0.7/ lib/active_record/connection_adapters/abstract_adapter.rb:109:indisable_referential_integrity’
    /Users/akkdio/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.0.7/
    lib/active_record/fixtures.rb:515:in block in create_fixtures' /Users/akkdio/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.7/ lib/active_support/benchmarkable.rb:55:insilence’
    /Users/akkdio/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.0.7/
    lib/active_record/fixtures.rb:514:in create_fixtures' /Users/akkdio/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.0.7/ lib/active_record/fixtures.rb:973:inload_fixtures’
    /Users/akkdio/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.0.7/
    lib/active_record/fixtures.rb:938:in setup_fixtures' /Users/akkdio/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.7/ lib/active_support/callbacks.rb:415:in_run_setup_callbacks’
    /Users/akkdio/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.7/
    lib/active_support/testing/setup_and_teardown.rb:34:in `run’

On 8 June 2011 14:59, akkdio [email protected] wrote:

test_the_truth(CartTest):
NoMethodError: undefined method `key?’ for “product :ruby
cart :one”:String

I don’t know the answer, but in your situation I would start by moving
away all my fixtures files. If that removes this problem (your tests
will then fail as there is no data of course) put them back until you
find the one that is causing the problem (if in fact it is one of the
fixtures files).

Colin

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs