Problem with composite primary keys, fixtures

3 views
Skip to first unread message

Daniel Berger

unread,
Sep 29, 2009, 5:46:30 PM9/29/09
to Composite Keys for ActiveRecord
Hi,

Rails 2.3.4
Ruby 1.8.7
CPK 2.3.2

I'm trying to load some fixture data in a unit test, but I'm hitting
this error:

NoMethodError: You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.first
vendor/gems/composite_primary_keys-2.3.2/lib/
composite_primary_keys/base.rb:261:in `find_from_ids'
test/unit/globe_school_test.rb:9:in `setup'

Where line 9 of globe_school_test.rb is:

# in the setup method
@record = globe_school(:zzustest)

And the globe_school.yml file is this:

zzustest:
schoolid: ZZUSTEST
schoolname: Test School Name
schoolgrades: MU
addressline1: 411 Southwest 24th Street
city: San Antonio
stateprovcode: TX
postalcode: 78207
countrycode: US
lifecyclecode: M
cyclechangedate: <%= Date.new(1997, 12, 15) %>

And the GlobeSchool model is:

class GlobeSchool < ActiveRecord::Base
set_table_name 'globe_school'
set_primary_keys :schoolid, :schoolname
end

Line 261 of composite_primary_keys.rb is from the find_from_ids
method:

if ids.first.is_a? String

Any ideas?

Regards,

Dan

toddwf

unread,
Oct 16, 2009, 11:34:58 AM10/16/09
to Composite Keys for ActiveRecord

I had put a patch out there, but someone claimed it didn't work. I'll
revisit in within the next week.

-Todd

Daniel Berger

unread,
Oct 19, 2009, 6:26:06 PM10/19/09
to Composite Keys for ActiveRecord
Thanks Todd. Can you point me to the patch? I'd be interested in
taking a look at it.

- Dan
Reply all
Reply to author
Forward
0 new messages