title: Rails Controller Method Not Reloading Page After Ajax Call
body: <p>So I've built an authentication method which acts as a before filter for the other methods in the controller. Basically, I would like the method to redirect to the root path if the user is not logged in. Here is my authenticate_user! before filter method:</p>
  
  <pre><code>def authenticate_user!
        unless current_user
          flash[:notice] = "Your session has ended. Please login again."
          render js: "window.location.pathname = '#{root_path}'"
        end
  end
  </code></pre>
  
  <p>The problem I'm having is that the window itself is not reloading, but rather the content element within the page and with the text displayed: "window.location.pathname = '/'". I'm not able to use a redirect_to (I found a <a href="https://stackoverflow.com/questions/13201351/rails-render-javascript-shows-text">similar question here</a>) because it only seems to send a certain content element back to the root_path (while elements like the navbar remain the same). This is why I've been looking for a full window reload. Any help would be much appreciated.</p>
  
  <p><strong>EDIT with server log</strong>:</p>
  
  <pre><code>Started GET "/projects/editHeader?fileName=test.csv" for 127.0.0.1 at 2014-07-04 10:37:21 -0400
  Processing by ProjectsController#editHeader as TEXT
    Parameters: {"fileName"=&gt;"test.csv"}
  Filter chain halted as :authenticate_user! rendered or redirected
  Completed 200 OK in 2ms (Views: 0.1ms | ActiveRecord: 0.0ms)
  
  
  Started GET "/projects/headerDataPreview?fileId=NaN" for 127.0.0.1 at 2014-07-04 10:37:21 -0400
  Processing by ProjectsController#headerDataPreview as TEXT
    Parameters: {"fileId"=&gt;"NaN"}
  Filter chain halted as :authenticate_user! rendered or redirected
  Completed 200 OK in 1ms (Views: 0.1ms | ActiveRecord: 0.0ms)
  </code></pre>