ruby on rails 4 - dropzone.js + paperclip uploading each image as its own post -


I am facing a strange problem.

I have posted_ as many attachments: imageable

and is_to imageable, polymorphic: true

I am trying to upload several images related to a single post. Dropzone.js

However, whenever I upload multiple files in dropzone-driven form, each image is displayed in my Post uploads as soon as I upload 4 images, I get 4 posts with each attached image. How to quantify do, which I attached to a position, which is associated with that post?

here post. Looks like JS : $ (document) .ready (function () disable // // disable search automatically Dropzone.autoDiscover = false; // upload our upload form Press with id $ ("# new_post") dropzone ({// maximum size 1MB to maxFilesize image size: 1, // changed paragraph passed to one accepted by // // Our Rail App nomenclature: " Post [attachments_attributes] [] [picture] ", // show add image on each image upload link: true});});

PostController

  create a deaf @ post = post. Action from act (post_params) @ post.save render Jason : {Message: "Success"},: Status = & gt; 200 and # you need to send an error header, otherwise Dropzone will not explain the response as # error: Jason: Render: {error: @ post.errors.full_messages.join (',')} ,: status = & Gt; Related sections of  _form.html.erb  for end of 400 end  

newform post operations:

  and lt;% = form_for (@ post, html: {class: "dropzone"}) do | F | & Gt%; .... & lt; Div class = "fallback" & gt; & Lt;% = f.label: Attachment% & gt; For & lt;% = f.fields_: Enclose | At | & Gt%; & Lt;% = at.file_field: PIC% & gt; & Lt;% end% & gt; & Lt; / Div & gt; .... & lt;% end% & gt;  

The ultimate name Posted in [attachment_attributes] [0] [Photo] As it appears in HTML, I suspect that this is the cause of this issue, But how can I change it so that the request uploads all the images related to a post?

Thanks in advance!

It seems that this is an issue which is untested but you have to use it for Dropzone Development Branch can use. This link contains details.


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -