Question

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.

Was it helpful?

Solution 2

Workaround:

one:
  id: 1

two:
  id: 2

...

OTHER TIPS

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top