There are interesting task: my active record ‘Event‘ entity can contain one ‘Attachment‘ PDF file. On the Create Event page, user can Upload this attachment BEFORE Submits that Event. Attachment uploads to Amazon via Ajax, progress-bar displays etc blablabla.
It should be displayed in_a_way:
= form_for @event do |e|
= e.text_field :name
= form_for @attach, :remote=>true, html=>{:multipart=>true} do |at|
= at.file_field :pdf, :accept=>"pdf", :size=>"1"
= at.submit
= e.submit
Yes, this is just pseudo-code, and I don’t mind how it can work, but the main idea is presents: [Submit Attachment] button should be placed inside the Event form.
How I can implement it? Maybe, just make some offset to nested Attachment form so it will be displayed inside Event form, or there are any others solutions?
………………………………………………
…………………………………………….
Solution: override form headers
This is a form for creating new event.
Inside this form, we need ajax file uploading.
There is a solution: mixing single form between two different types of submits: ajax(js) and html:
Now, to upload file via AJAX use:
any questions?