2016-07-25 2 views
0

누에 고치를 사용하여 파일을 첨부합니다. 질문을 편집 할 때 파일을 제거 할 수 있어야합니다. 필자는이 정답 인 경우 편집누에 고치 레일, atached 파일 이름을 얻는 방법

 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를 –

관련 문제