I have a series of remote forms on a page, each of which should be able to upload a file when the object is updated or created. I've checked and tested thoroughly in development, and as long as I'm using Remotipart this seems to work just fine.
However, this morning I pushed my changes up to my staging server on Heroku, and when I try to submit one of these forms with a file upload, I get a 406 Not Acceptable
response from the server. So here my page does not get updated because I don't get my expected js template response from the server. However, if I reload the page, the file I tried to upload shows up just fine.
The forms are created using simple_form (with remote: true
) and I'm using Carrierwave with Fog to upload the files to S3 (also tested in development, so I don't think it's that).
The network inspector shows the same kind of data as far as I can tell. I see no significant differences in the request payload.
I don't know what I'm doing wrong (if anything). Has anyone else experienced this or perhaps have an idea what's wrong?
Update
So I've figured at least one thing out. My controller was only handling js
format requests. I handled html
formatted requests by redirecting to another path, and the html of that page is now sent back as the ajax response. What I can't seem to figure out is why, when the content types and everything seem to be the same on both development and staging, do the responses get sent/rendered in the wrong format.
Welp, I solved it. Turns out the javascript was getting included, but none of the middleware. On closer inspection, I found that a few of my gems were placed in the assets
group in the Gemfile, which would get included on development environments, but not in production.
I moved remotipart out of the assets group and everything works fine now.