Tuesday, April 24, 2012

AJAX file-upload capability to remote forms in Rails 3. but HOW??

Well this was something strange that I was hitting the other time when was doing the file upload in rails 3.1+ from an AJAX form

I was trying to upload a file in a AJAX form (driven by jQuery) and every time i click submit it used to be normal synchronous request while any submit without file field was going correct as an AJAX request.

Googled it out but not much of help in the beginning but later via some articles came to know people using iframe for file upload on ajax (in rails) how and why this happened I don't know but yes it is there.

I was expected to come out of the situation and complete the work in time, and gem Remotipart came to help...

Will debug it later and currently I don't know much of, how it enables this functionality but it worked flawless even without changing a single line of code in my remote form with file upload.

Just added it to gem file and updated application.js (as is mentioned in the documentation of gem) and it just worked!! 
I know it sounds innocently non-develop-ish, pardon me for that.. will debug more and update soon but for the time being hit the URL here and get yourself out of this situation http://os.alfajango.com/remotipart/

In the mean time anybody want to share any information on this.. most welcome please comment and spread the knowledge :)

No comments:

Post a Comment