0
我正在研究與Dropbox具有相似功能的Ruby on Rails項目。寶石使用:使用引導模式呈現編輯部分表單
- carrierwave:上傳文件
- acts_as_tree:文件夾目錄
- 苗條:清潔HTML
- 引導4
我試圖將引導用於呈現編輯表單的模態,以便用戶能夠編輯我在模型中的file_name屬性。
- @documents.each do |document|
= link_to document.file.filename, document.file.url
b = document.file_name
= number_to_human_size(document.file.size, :precision => 2)
= document.content_type
= document.updated_at
= link_to "Download", document.file.url
#renameButton.button.btn.btn-primary data-toggle="modal" data-target="#renameModal" Rename
#renameModal.modal.fade tabindex="=1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true"
.modal-dialog role="document"
.modal-content
.modal-header
#exampleModalLabel.h5.modal-title Rename folder
button.close data-dismiss="modal" aria-label="Close"
span aria-hidden="true" ×
.modal-body
= form_for document do |f|
= f.label :name
= f.text_field :file_name
= f.submit
.modal-footer
button.btn.btn-outline-success data-dismiss="modal" aria-hidden="true" Close
button.btn.btn-outline-danger Save changes
= link_to "Delete", document, :confirm => 'Are you sure?', :method => :delete
我的問題是,每當我點擊我的任何「重命名」按鈕,模式裏面所呈現的編輯表單總是指向1號文件條目,而不是選擇之一。
我認爲在我的do-loop中有一個模式會導致這個問題。
有沒有辦法解決這個問題?
這工作就像一個魅力!非常感謝你mayank! –