Daniel Berger
unread,Sep 29, 2009, 5:46:30 PM9/29/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
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