link
link
>
There are several solutions to do this. Today I use the solution to CarrierWave + DropDzone
Philip,
The HTTP POST / PUT method allows you to make a client & server for binary files.
In order to make your controller accept this type of file you will have to prepare a MODEL to capture this file to make it 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 configure the carrierwave
link
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"