命名装置的问题
我正在使用 Rails 2.3,并且有以下关联:
User: has_many :photos has_many :classifications Photo: belongs_to :user has_many :classifications Classification: belongs_to :user belongs_to :photo
我对每个模型都有一个固定装置:
users.yml: tester: username: tester ... photos.yml: bianco: id: 1 user: tester ... classifications.yml: classificazione_bianco: photo: bianco user: tester ...
所有关联都工作良好,除了分类的 photo_id 被设置为不存在的数字。 为什么命名关联在这种情况下不起作用?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Rails 不支持命名关联以及直接设置的 ID。
Rails doesn't support named associations along with IDs which have been set directly.