【问题标题】:Nested Attributes not saving inside a form in Rails嵌套属性未保存在 Rails 的表单中
【发布时间】:2011-10-15 06:09:33
【问题描述】:

我有 Tours,其中有_many Photos... Photos belongs_to 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

字段填充正确,但是当我保存表单时......它们没有更新......

有什么线索吗?

【问题讨论】:

    标签: ruby-on-rails-3 nested-attributes formtastic


    【解决方案1】:

    Tour 模型只需要 attr_accessible :photo_attributes

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多