It made me all day all day.
My application provides the loading of documents, after downloading it runs create.js.erb and adds a new entry to the page.
My HTML looks like this:
<div id="doc_upload"> <%= form_for Document.new, remote: true do |f| %> <%= f.file_field :file, multiple: true, name: "document[file]" %> <%= f.hidden_field :plot_id %> <%= f.submit 'upload' %> <% end %> </div>
I have a create.js.erb file in the docs directory. I am currently using jquery file upload, and loading drag and drop files does not cause problems. However, when I use this form to manually select a file and upload, I get:
- HTTP Error 406
- page redirected to / documents
- when I return, the file was successfully downloaded and saved.
The headings are as follows.
Request URL:http://localhost:3000/documents Request Method:POST Status Code:406 Not Acceptable Request Headersview source Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8}
my controller:
def create @document = Document.create(params[:document]) respond_to do |format| format.js end end
As I said, this really makes me scratch my head, as the Ajax request does not seem to work. Does this mean that this could be due to unobtrusive JS not collecting the remote true data type. This is the only reason I can think of a redirect.
If so, how do I confirm and correct this?
Any help would be great.
Ross
source share