title: Rails redirect_to is redirecting from https (correct) to http (incorrect)?
body: <p>In my Rails 4 app, I have a <code>before_action</code> requiring the user to be logged in, like so:</p>
  
  <pre><code>class ApplicationController &lt; ActionController::Base
    protect_from_forgery with: :exception
    before_action :require_login
  
    def require_login
      unless logged_in?
        flash[:alert] = "You must be logged in to access this section."
        redirect_to login_path
      end
    end
  
    def logged_in?
      # more logic
    end
  end
  </code></pre>
  
  <p>When I visit <code>example.com</code> without being logged in, I get redirected to <code>example.com/login</code> as expected. However, I see this error in the console:</p>
  
  <pre><code>The page at 'https://example.com/login' was loaded over HTTPS, but displayed
  insecure content from 'http://example.com/login': this content should also
  be loaded over HTTPS.
  </code></pre>
  
  <p>The network tab appears to indicate that my <code>redirect_to</code> is pointing me to <code>HTTP</code> and not <code>HTTPS</code>. When it hits the HTTP, it then automatically redirects to <code>HTTPS</code>.</p>
  
  <pre><code>Request URL:http://example.com/login
  Request Method:GET
  Status Code:301 Moved Permanently
  
  # In the response headers:
  Location:https://example.com/login
  </code></pre>
  
  <p>Is there a way to tell the <code>redirect_to</code> that it should use <code>HHTPS</code> instead of <code>HTTP</code>, or is this an nginx config? I thought that using <code>login_path</code> as opposed to <code>login_url</code> would fix the issue since it should be relative to the base, but that didn't seem to work.</p>
  
  <hr>
  
  <p>Update:</p>
  
  <p>I thought about using <code>force_ssl</code> as well but was worried that I was taking a hammer to a push pin. Feel free to correct me if I'm mistaken.</p>