Hello, I’m learning rails and creating a small project,
Someone could tell me how can I upload multiple images with paperclip in rails 4?
Thank you very much, I hope someone can help me.
Greetings.
Hello, I’m learning rails and creating a small project,
Someone could tell me how can I upload multiple images with paperclip in rails 4?
Thank you very much, I hope someone can help me.
Greetings.
C’mon, mate.
Have you at least tried to google it?
Apparently no.
I’ll give you a hand with that
Less time being an asshat and more time learning what the word "help" means. And yes, I will admit by all technicality you did "help" but by all semantics you did not help by the standards of which make you a human.
Alright, I might have exaggerated.
Hey Eugenio Tambur, if you took my response as Jordon did, pardon me. I didn’t mean to be an asshat as he says(I’m a cool guy), but, I still reckon that by trying to find out the solution of a problem or learning anything new on your own first, will definitely be one of the best way to enhance/improve your skills/knowledge.
You want to use paperclip for handling files and rails 4 as framework. All you need is the implementation for uploading multiple images.
There are many javascript plugins out there if you want go for JS way. Following are some easy to integrate plugins:
Which is easy to integrate and usages Plupload gem.
Following are some links which may help you:
Regards, Lauree (Ruby on Rails Developer)
Paperclip supports multiple files in a single upload anyway. All you need to do is make a form on another parent model (that model should be set to `accepts_nested_attributes_for` the model you have attached your file to), add the multiple => true flag to your file field, and force the name of the file field to conform with this pattern:
:name => 'parent_model_name[attachment_model_name][attachment_name]
So for User has_many :avatars, accepts_nested_attributes_for :avatars and Avatar has_attached_file :image, the field would be named:
'user[avatars_attributes][image]'
Upload that nested form and as many Avatar objects as your form field held individual files will be magically created. No drama, no jQuery, no plugins in the browser*.
Walter
*Where by browser I mean **modern** browser.
Hi, You can use nested_form gem for the same.You would be able to add more and remove existing image.
HI
Firstly we need install paperclip, imagemagic on your machine , then we need define relation to the model suppose product and product_images. we need to define accepts_nested_attributes_for :product_images in your model then
when you create object of model we need build product object to the product_iamges model. In your view create _form.html.erb and _product_image_fields.html.erb. In your form.html.erb write above code