Nested Form Using Paperclip

Nested paperclip form with multiple images

Multiple upload with Paperclip in ror

Check this answer!

You may use paperclip to upload pics and nested_form for multiple uploading. The question above will help you to connect all this. If still you can't do it, write me. I'm just solve that issue.

Nested attributes using paperclip rails 4

What's in your deal_param method?
Do you permit deal_photos' attributes in it?
If no then do something like

def deal_params
params.require(:deal).permit(deal_attr1, deal_attr2,...., deal_photos_attributes: [:deal_photo_attr1, ...])
end

Also, do you get a deal_id in your deal_photos in view?

How to use link_to inside a nested form in Rails?

I think you should be able to do

f.object.url

So:

%fieldset
.field
= f.label :file
= f.file_field :file
# Not sure if it would produce a Nil error on the new form.
# given how the f object wouldn't yet have a url
- if f.object.url
= link_to f.object.url
.field
= f.hidden_field :_destroy
= link_to "Remove File", '#', class: "remove_fields"

Rails 4 nested form image preview with Paperclip

I'm not sure if this is the problem, but you shouldn't have multiple HTML elements with identical IDs. Try changing the JS so that it uses the class of file fields instead.

$(function() {
$('.fileBt').on('change', function(event) {
...

Note that you probably want to rename that class to something more meaningful and specific to image upload fields. For example ".photo-upload-field" would work :)

How to use nested forms in Rails with paperclip?

Pretty sure you need an = on that first line, so

<%= f.fields_for(:postimages) ... %>


Related Topics



Leave a reply



Submit