Problem with named fixtures
-
13-09-2019 - |
Question
I am working with Rails 2.3 and I have the following associations:
User: has_many :photos has_many :classifications Photo: belongs_to :user has_many :classifications Classification: belongs_to :user belongs_to :photo
I have a fixture for each model:
users.yml: tester: username: tester ... photos.yml: bianco: id: 1 user: tester ... classifications.yml: classificazione_bianco: photo: bianco user: tester ...
All asociations work well, except from classification's photo_id which is set to a non-existent number. Why the named association doesn't work in this case?
Solution
Rails doesn't support named associations along with IDs which have been set directly.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow