title: rails redirect_to format html sends response in js
body: <p>I made a before_filter in some of my controller to redirect keyword searches to the parent controller</p>
  
  <p>It's very simple:</p>
  
  <pre><code>  before_filter :redirect_search
    def redirect_search
      redirect_to controller: "buildings", action: "index", format: "html" if params[:q].present?
    end
  </code></pre>
  
  <p>Please note that the keyword_search is sent in "js" format</p>
  
  <p>Everything seems to work. When I look at the server, I can see that the buildings/index is run and that the page is rendered but nothing happens in the browser.</p>
  
  <p>In the browser's console I see this </p>
  
  <pre><code>GET http://localhost:3000/buildings.html 200 OK
  </code></pre>
  
  <p>It has the html page in the response body</p>
  
  <p>This means that buildings/index is run as html but then sent as js to the browser.</p>
  
  <p>Why is that so? How can I fix it?</p>