views:

62

answers:

1

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?

+1  A: 

Rails doesn't support named associations along with IDs which have been set directly.

collimarco