Add remote: => true on Form_for
You've inserted the :remote = true
right AFTER the parameter list. Just leave off the parenthesis.
<%= form_for @document, :remote => true do |f| %>
<%= form_for(@document, :remote => true) do |f| %>
...
<% end %>
reefer this : http://apidock.com/rails/ActionView/Helpers/FormHelper/form_for