Reputation: 3468
I have the ff. ActiveRecord which I use only for the ID it generates:
class SomeTable < ActiveRecord::Base
end
I thought that one could specify fixtures for it through:
one:
two:
Which I refer to in other fixtures as:
other_one:
some_field: some value
some_table: one
But when I run my tests, I get:
Fixture::FormatError: Bad data for SomeTable fixture named one (nil)
Does anybody know how to specify empty or nil fixtures then? If this is not possible, either a work-around or an alternative solution is acceptable.
Upvotes: 2
Views: 1460
Reputation: 467
You shouldn't set the id explicitly if you want to use the labels as foreign key in some other fixture file.
# in users.yml
one: {}
two: {}
# now in posts.yml, this works:
one:
user: one
Upvotes: 6