0

I have a form that uses rails jquery-UJS to submit asynchronously. It works fine as long as there is not a file input. When I add a file input, the form stops submitting asynchronously, and instead submits normally (full page reload).

I found out that since browsers do not support ajax files, UJS will fire the ajax:aborted:file event if a populated file input exists in the form. http://robots.thoughtbot.com/a-tour-of-rails-jquery-ujs

The proposed solution is to use remotipart. https://github.com/JangoSteve/remotipart. However this gem hasn't been touched since 2013. I believe I read somewhere that Rails 4 includes this functionality.

What is the Rails 4 convention for async file uploads?

Don P
  • 60,113
  • 114
  • 300
  • 432
  • 1
    Did u even try to use `remotipart` gem? Doing a search in its issues list, it looks like some people have used it successfully with Rails 4. Not sure if it will work with latest version, but might be worth a try. – San Jul 10 '14 at 16:54
  • Checkout http://www.sitepoint.com/asynchronous-file-uploads-rails/, they use `remotipart` and it seems to work fine. – CWitty Jul 10 '14 at 16:58
  • It seems that `remotipart` hooks into the the rails ujs and listens for the event. – CWitty Jul 10 '14 at 17:04

0 Answers0