2016-07-25 49 views
0

我使用茧来附加文件。编辑问题时,我需要能够删除文件。林停留在得到确切的文件名渲染编辑茧轨道,如何获得缓存文件名

 div.edit_question 
    =form_for @question, remote: true do |f|  
    = f.label :title, class: 'label_hidden' 
    = f.text_field :title 
    br 
    = f.label :body, class: 'label_hidden' 
    = f.text_area :body 
    br 
    = f.fields_for :attachments do |f|     
     .nested-fields   
     = link_to_remove_association "remove #{ NAME HERE }", f  
    br 
    = f.submit 'Update' 

回答

0

结案))

=form_for @question, remote: true do |f|  
    = f.label :title, class: 'label_hidden' 
    = f.text_field :title 
    br 
    = f.label :body, class: 'label_hidden' 
    = f.text_area :body 
    br 
    - @question.attachments.each do |att| 
    = f.fields_for att do |f|     
     .nested-fields   
     = link_to_remove_association "remove #{ att.file.filename }", f  
    br 
    = f.submit 'Update' 
+0

时,如果这是正确的答案删除,请把它标记为正确答案:d –