https://www.sitepoint.com/asynchronous-file-uploads-rails/
https://github.com/JangoSteve/remotipart
https://medium.com/rails-ember-beyond/ajax-file-upload-in-rails-using-dropzone-and-carrierwave-6f5436fdfdb0#. 4paxrz751
There are several solutions to do this. Today I use the solution Carrierwave + Dropdzone
Felipe,
The HTTP POST/PUT method allows you to make a client & server connection of binary files.
In order to get your controller to accept this type of file you will have to prepare a MODEL to capture this file to transform it into the desired file "PDF, JPG,PNG....
model/Asset.Rb
class Asset < ActiveRecord::Base
belongs_to :assetable, polymorphic: true
mount_uploader :file, FileUploader
end
remember to look at how to set up the carrierwave
http://railscasts.com/episodes/253-carrierwave-file-uploads
model/nfes.Rb
has_one :asset, :class_name => "Asset", as: :assetable, dependent: :destroy
Nfescontroller.Rb
respond_to :html, :xml, :json, :js
...
private
def nfe_params
params.require(:nfe).permit(:build_id, :due_at, asset_attributes:[:id, :file])
end
views/new.html.slim
form_for @nfe, html: { multipart: true, class: "dropzone"}, method: :post do |f|
div.fallback
- f.object.build_asset if f.object.asset.blank?
= f.fields_for :asset do |asset|
= asset.file_field :file
= f.submit "Upload"
My question is how does it move up the file and when I click on
submit
, it change the content of the page, you could give an example here?– Felipe Avelar
@Breno Perucchi avoid posting only links as answers, put the relevant parts in your reply.
– MagicHat
@magicHat The question was very general. It did not involve, how to solve this or I’m having trouble with it and yes I would like a solution to it. I didn’t know links weren’t appropriate for answers.
– Breno Perucchi
I think when it is so better to put in the comment... I don’t know... But the fact of putting the links, it is because it leaves the air, there is broken,,,
– MagicHat
@Magichat posted something consistent
– Breno Perucchi
Look at the difference...
– MagicHat
@Felipeavelar worked?
– Breno Perucchi