Ruby on rails 3 form_helpers Rails 3-在循环中包含对象

Ruby on rails 3 form_helpers Rails 3-在循环中包含对象,ruby-on-rails-3,nested-attributes,form-helpers,Ruby On Rails 3,Nested Attributes,Form Helpers,旅游有很多:照片,照片属于:旅游 巡更的字段是:title,:description 照片的字段为:alt、:image(path)、:tour\u id 巡更接受\u嵌套的\u属性\u用于:照片 旅游attr\u可访问:照片属性 -- 在Tours表单中,我希望在保存后返回表单中相应的Tours照片,以便用户可以查看他们上传的照片并添加Alt标记 这是表单的外观,但我不知道如何将任何保存的图像恢复到表单中 = semantic_form_for ([:admin, @tour]), :html

旅游
有很多:照片
,照片
属于:旅游

巡更的字段是
:title,:description

照片的字段为:alt、:image(path)、:tour\u id

巡更
接受\u嵌套的\u属性\u用于:照片

旅游
attr\u可访问:照片属性

--

在Tours表单中,我希望在保存后返回表单中相应的Tours照片,以便用户可以查看他们上传的照片并添加Alt标记

这是表单的外观,但我不知道如何将任何保存的图像恢复到表单中

= semantic_form_for ([:admin, @tour]), :html => {:multipart => true} do |f|
...
  - unless @tour.new_record?
    = semantic_fields_for Photo.new do |f|
      = f.file_field :image, :rel => tour_photos_path(@tour)
    - else
      You must save the tour, to be able add photos.

    = f.semantic_fields_for :photos, @tour.photos do |p|

         // If there is a photo, somehow display that image in this form loop...
         = image_tag ## WHAT COULD I PUT HERE? ##

         = f.input :remove_image, :as => :boolean

         = p.inputs

我很困惑,因为很明显,form_助手可以将保存的表单元素带回表单字段中。。但是我不知道如何在图像标签中使用其中一个保存的元素…

你的问题有点难理解,但是像这样的东西呢

- @tour.photos.each do |photo|
  = image_tag photo.path
  = f.input :remove_image, :as => :boolean
  # etc...