I want to upload multiple images with dropzone.js on new post form.(Rails 4) I can upload images smoothly but I can not associate with new post because it doesn't have an id yet.
To do this, what should be the strategy?
Thanks.
I want to upload multiple images with dropzone.js on new post form.(Rails 4) I can upload images smoothly but I can not associate with new post because it doesn't have an id yet.
To do this, what should be the strategy?
Thanks.
i had the same problem, don't know, whether my solution is by the book, but i solved it so that when i create new parent, it gets saved to database immediately and then goes straight into edit mode, when it already has an ID.
I have two models Location (parent - has many) and Photo (child belongs to).
In my location view i put:
<%= link_to t('new_location'), locations_path(:user_id => current_user.id), :method => :post, class: 'btn btn-success' %>
In my locations_controller.rb, i have redirect to edit action on create. And that is it. When you create new location, it gets immediately saved and redirected to edit action, where i can upload images via jquery belonging to that location, because it allready has an ID.
BR, Luka
© 2022 - 2024 — McMap. All rights reserved.