Rails authenticate_or_request_with_http_basic response
<p>I'm trying to redirect to the root_path if authentication fails.
Currently, it's just changing the body of the page with HTTP Basic: Access denied.</p>

<p>Here is my controller:</p>

<pre><code>class ProjectsController &lt; ApplicationController
 before_filter :http_basic_auth, only: [:show]

  def http_basic_auth
    if (authenticate_or_request_with_http_basic do |user, password| password == @project.passcode &amp;&amp; user == @project.passcode end if @project.private?)
    true
    else
      response.headers["Location"] = url_for(root_path)
    end
  end

end
</code></pre>

<p>Researched the following but I'm still not able to get it right:<br>
<a href="https://stackoverflow.com/questions/12084431/rails-what-is-the-location-option-for-in-the-render-method">Rails: What is the location option for in the render method</a><br></p>

<p><a href="http://api.rubyonrails.org/classes/ActionController/HttpAuthentication/Basic/ControllerMethods.html#method-i-authenticate_with_http_basic" rel="nofollow noreferrer">http://api.rubyonrails.org/classes/ActionController/HttpAuthentication/Basic/ControllerMethods.html#method-i-authenticate_with_http_basic</a>
<br></p>

<p><a href="http://guides.rubyonrails.org/v2.3.11/action_controller_overview.html#the-request-and-response-objects" rel="nofollow noreferrer">http://guides.rubyonrails.org/v2.3.11/action_controller_overview.html#the-request-and-response-objects</a></p>