Add nested documents to proposal form.

This commit is contained in:
Senén Rodero Rodríguez
2017-08-23 18:26:05 +02:00
parent 723173ae39
commit cc89907bff
25 changed files with 501 additions and 104 deletions

View File

@@ -1,7 +1,7 @@
module DocumentsHelper
def document_attachment_file_name(document)
document.attachment_file_name if document.attachment.exists?
document.attachment_file_name
end
def errors_on_attachment(document)
@@ -22,4 +22,18 @@ module DocumentsHelper
bytes / Numeric::MEGABYTE
end
def document_nested_field_name(document, index, field)
parent = document.documentable_type.constantize.name.downcase
"#{parent}[documents_attributes][#{index}][#{field}]"
end
def document_nested_field_id(document, index, field)
parent = document.documentable_type.constantize.name.downcase
"#{parent}_documents_attributes_#{index}_#{field}"
end
def document_nested_field_wrapper_id(index)
"document_#{index}"
end
end