Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ziaulrehman40/7dd374c5571409433396d1d544aaaaf5 to your computer and use it in GitHub Desktop.
Save ziaulrehman40/7dd374c5571409433396d1d544aaaaf5 to your computer and use it in GitHub Desktop.
blueimp/jQuery-File-Upload rails gem through rails-assets

blueimp/jQuery-File-Upload is a very helpful plugin, but using it in rails(<5.1, in rails 5.1 and above, we have webpack and yarn support, i would love to see how these work and if anyone can add how to add this library using that that would be great) is a pain like every other js library.
This is to have record of how i managed to get it working on rails, without manually adding all js files.

Using rails-assets to add gemfile https://rails-assets.org/#/components/jquery-file-upload
Pre-req: Jquery-ui configured.

Gemfile:
gem 'rails-assets-', source: 'https://rails-assets.org'
This install all dependent gems also.

And in application.coffee(in my case its coffee)
#= require jquery-file-upload

"But this does not require all the required files."

So, replace above lines with these...

#= require blueimp-load-image/js/load-image
#= require blueimp-load-image/js/load-image-scale
#= require blueimp-load-image/js/load-image-meta
#= require blueimp-load-image/js/load-image-fetch
#= require blueimp-load-image/js/load-image-exif
#= require blueimp-load-image/js/load-image-exif-map
#= require blueimp-load-image/js/load-image-orientation
#= require blueimp-canvas-to-blob/js/canvas-to-blob
#= require jquery-file-upload/vendor/jquery.ui.widget
#= require jquery-file-upload/jquery.fileupload
#= require jquery-file-upload/jquery.fileupload-ui
#= require jquery-file-upload/jquery.iframe-transport
#= require jquery-file-upload/jquery.fileupload-process
#= require jquery-file-upload/jquery.fileupload-image
#= require jquery-file-upload/jquery.fileupload-audio
#= require jquery-file-upload/jquery.fileupload-video
#= require jquery-file-upload/jquery.fileupload-validate

Yes, ALL of these lines, only way I was able to get all the function(I was using) to work.
Don't forget this requires JQuery-ui pre configured and required before these lines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment