title: Rails form_for with file_field and remote => true and format => :js
body: <p>I am submitting a form_for with a file_field in it. When the form is submitted with a post, the controller responds with a .js file which will be executed.</p>
  
  <p>The file_field is optional.</p>
  
  <p>When I upload a file, the js file is opened in a new document (as a simple text file) and the js is not executed. When I don't upload any file, the response div is updated. I want the update success to be notified in the response div or a failure message independent of the file upload.</p>
  
  <p>May be this is done for some security reasons? Is there some workaround for people who want to be able to do this?</p>
  
  <p>Roughly,</p>
  
  <p>Form partial _action.html.erb:</p>
  
  <pre><code>&lt;div id="response"&gt;&lt;/div&gt;
  &lt;%= form_for ... :remote =&gt; true, :url =&gt; {..., :format =&gt; :js} do |f| %&gt;
      ...
      &lt;%= f.file_field :name %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>Controller::action</p>
  
  <pre><code> if not request.post?
      render :partial =&gt; 'controller/action'
      return
   else
      @response = "save was successful";
      # renders the action.js.erb
   end
  </code></pre>
  
  <p>action.js.erb:</p>
  
  <pre><code>$("#response").html("&lt;%= @response %&gt;");
  </code></pre>