Remove new_nested action from images controller. Use cocoon gem to manage new nested fields creation on images.

This commit is contained in:
Senén Rodero Rodríguez
2017-09-23 17:14:32 +02:00
parent 88a7a29d27
commit f8d78ec4ab
23 changed files with 263 additions and 268 deletions

View File

@@ -46,23 +46,19 @@ module DocumentsHelper
end
def render_attachment(builder, document)
html = builder.file_field :attachment,
label: false,
accept: accepted_content_types_extensions(document.documentable_type.constantize),
class: 'js-document-attachment',
data: {
url: document_direct_upload_url(document),
nested_document: true
}
if document.attachment.blank? && document.cached_attachment.blank?
klass = document.errors[:attachment].any? ? "error" : ""
html += builder.label :attachment, t("documents.upload_document"), class: "button hollow"
if document.errors[:attachment].any?
html += content_tag :small, class: "error" do
document_errors_on_attachment(document)
end
end
end
klass = document.errors[:attachment].any? ? "error" : ""
klass = document.persisted? ? " hide" : ""
html = builder.label :attachment,
t("documents.upload_document"),
class: "button hollow #{klass}"
html += builder.file_field :attachment,
label: false,
accept: accepted_content_types_extensions(document.documentable_type.constantize),
class: 'js-document-attachment',
data: {
url: document_direct_upload_url(document),
nested_document: true
}
html
end