嵌套属性未保存在 Rails 的表单内
我有 Tours,它有很多照片...照片属于 Tours...这一切都很顺利,但是当我尝试编辑上传照片的属性时,它不会保存在数据库中...(我导入了一些数据,这保存得很好,但它不会保存任何更改)
我有一个带有nested_attributes的表单
= semantic_form_for ([:admin, @tour]), :html => {:multipart => true} do |f|
...
- @tour.photos.each do |photo|
...
= f.semantic_fields_for photo do |p|
...
= p.inputs :alt, :description, :temp_src, :remote_image_url
字段正确填充,但是当我保存表单时..它们不会更新...
有任何线索吗?
I have Tours, which has_many Photos... Photos belong_to Tours... This is all going okay, but when I try to edit the attributes of an uploaded photo, it will not save in the database... ( I have imported some data, and this saves fine, but it just won't save any changes)
I have a form with nested_attributes
= semantic_form_for ([:admin, @tour]), :html => {:multipart => true} do |f|
...
- @tour.photos.each do |photo|
...
= f.semantic_fields_for photo do |p|
...
= p.inputs :alt, :description, :temp_src, :remote_image_url
The fields populate correctly, but when I save the form.. they do not update...
Any clues?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Tour 模型只需要 attr_accessible :photo_attributes
The Tour model simply needed attr_accessible :photo_attributes