Looking for help with NoMethodError: undefined method `key?' for #<String:0x4795488>

Hi all,

Any help with this would be appreciated. I’m using instant rails,
updated to 2.2.2, on Windows XP.

I’ve created my DB and scaffolded a few things and put some fixtures
into place, and when I run the tests I get many errors that look like
this:


  1. Error:
    test_the_truth(EntityTest):
    NoMethodError: undefined method key?' for #<String:0x4795488> C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/ active_record/fixtures.rb:584:ininsert_fixtures’
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/
    active_record/fixtures.rb:583:in each' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/ active_record/fixtures.rb:583:ininsert_fixtures’
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/
    active_record/fixtures.rb:577:in each' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/ active_record/fixtures.rb:577:ininsert_fixtures’
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/
    active_record/fixtures.rb:520:in create_fixtures' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/ active_record/fixtures.rb:520:ineach’
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/
    active_record/fixtures.rb:520:in create_fixtures' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/ active_record/connection_adapters/abstract/database_statements.rb: 66:intransaction’
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/
    active_record/fixtures.rb:518:in create_fixtures' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/ active_record/connection_adapters/mysql_adapter.rb:254:indisable_referential_integrity’
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/
    active_record/fixtures.rb:509:in create_fixtures' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/ active_record/base.rb:1398:insilence’
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/
    active_record/fixtures.rb:508:in create_fixtures' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/ active_record/fixtures.rb:964:inload_fixtures’
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/
    active_record/fixtures.rb:930:in setup_fixtures' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/ lib/active_support/callbacks.rb:178:insend’
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/
    lib/active_support/callbacks.rb:178:in evaluate_method' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/ lib/active_support/callbacks.rb:166:incall’
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/
    lib/active_support/callbacks.rb:90:in run' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/ lib/active_support/callbacks.rb:90:ineach’
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/
    lib/active_support/callbacks.rb:90:in send' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/ lib/active_support/callbacks.rb:90:inrun’
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/
    lib/active_support/callbacks.rb:277:in run_callbacks' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/ lib/active_support/testing/setup_and_teardown.rb:58:inrun’

My entity model is dead simple at the moment-
class Entity < ActiveRecord::Base
end

My DB table (entities) has these fields-
id
created_at
updated_at
taxa_order
taxa_family
taxa_genus
taxa_species
common_name
short_description
description

it was created using this migration code-
create_table :entities do |t|
t.timestamps
t.column “taxa_order”, :string, :limit => 127, :default
=> “”, :null => false
t.column “taxa_family”, :string, :limit => 127, :default
=> “”, :null => false
t.column “taxa_genus”, :string, :limit => 127, :default
=> “”, :null => false
t.column “taxa_species”, :string, :limit => 127, :default
=> “”, :null => false
t.column “common_name”, :string, :limit => 127, :default
=> “”, :null => false
t.column “short_description”, :string, :limit => 255, :default
=> “”, :null => false
t.column “description”, :text, :default
=> “”, :null => false
end
add_index “entities”, [“taxa_order”], :name => “taxa_order”
add_index “entities”, [“taxa_family”], :name => “taxa_family”
add_index “entities”, [“taxa_genus”], :name => “taxa_genus”
add_index “entities”, [“taxa_species”], :name => “taxa_species”
add_index “entities”, [“common_name”], :name => “common_name”

and my entities.yml fixture file looks like this-
one:
taxa_order:testorder
taxa_family:testfamily
taxa_genus:testgenus
taxa_species:testspecies
common_name:testcommonname
short_description:this is a short description
description:this is a longer description, it just goes on and on and
on and on and on and on and on and on and on and on and on and on and
on and on

I suspect the error has something to do with the timestamp stuff
(fixtures.rb:584 seems to refer to time stamp fields), but I have no
idea what exactly is causing the problem, nor how to go about fixing
it. Anyone have any ideas? Thanks!

-Chris W.

On 2 Feb 2009, at 03:47, Chris wrote:

Hi all,

Any help with this would be appreciated. I’m using instant rails,
updated to 2.2.2, on Windows XP.

I’ve created my DB and scaffolded a few things and put some fixtures
into place, and when I run the tests I get many errors that look like
this:

i’d guess it’s one of your fixtures (the yml files) that isn’t
indented properly

Fred

Thanks! Turned out not to be indenting, but that was the clue I needed
to take a closer look at my fixture syntax. I’d accidentally removed
the space after the : in name value pairs in one of my files. I hadn’t
realized how format sensitive yaml is. Now on to the fun stuff…

-Chris

On Mon, Feb 2, 2009 at 7:46 AM, Frederick C.