Rails 4 - json.jbuilder with remotipart


My Application details

  1. Rails 4.0 application
  2. Remotipart gem remotipart (1.2.1)
  3. Using json.jbuilder to return a response.
  4. Using paperclip gem for uploading file paperclip (~> 4.1)

I have a form with remote: true and multipart: true. I am redering a json.jbuilder template after submitting the form. I have ajax:successcallback on the form.

When I submit a form without an attachment then it renders json.jbuilder template and ajax:success callback works. But if I submit a form with an attachment then the form gets submitted rendering json.jbuilder file. But the ajax:success callback doesn't work.

I have been struggling with this issue since 2 days.

Thanks in advance

I was trying to use

hidden_field "format", :json

But it didn't work. After adding option

:'data-type' => :json 

for the form_forit worked.

This video can help you solving your question :)
By: admin