title: Phoenix 1.4 How to alias Routes.page_path in a Plug
body: <p>I've tried a couple different iterations but I keep getting this error when compiling:</p>
  
  <pre><code>Routes.session_path/2 is undefined (module Routes is not available)
  </code></pre>
  
  <p>My Code:</p>
  
  <pre class="lang-ex prettyprint-override"><code>defmodule Blackbook.Plugs.RequireAuth do
      import Plug.Conn
      import Phoenix.Controller
      alias Blackbook.Router.Helpers, as: Routes
  
      def init(_params) do
      end
  
      def call(conn, _params) do
          if conn.assigns[:current_user] do
              conn
          else
              conn
              |&gt; put_flash(:error, "You must be logged in.")
              |&gt; redirect(to: Routes.session_path(conn, :new))
              |&gt; halt()
          end
      end
  end
  </code></pre>
  
  <p>It's a little different in Phoenix 1.4, tried referring to documentation here <a href="https://hexdocs.pm/phoenix/Phoenix.Router.html" rel="nofollow noreferrer">https://hexdocs.pm/phoenix/Phoenix.Router.html</a> but still no luck. </p>