title: Rails 4 custom path helper
body: <p>I would like to customize my path helpers in Rails 4.</p>
  
  <p>I have a Site5 website (which uses Apache server) with multiple subdomains.  I have rewrite rules in my <code>.htaccess</code> file which adds the folder name to the url.  For example</p>
  
  <pre><code>cs1337.mysite.com/login
  </code></pre>
  
  <p>is rewritten to</p>
  
  <pre><code>cs1337.mysite.com/cs1337/login
  </code></pre>
  
  <p>In routes.rb, I have added a scope in routes.rb:</p>
  
  <pre><code>scope '/cs1337' do
    get '/login', to: 'sessions#new', as: :login
    # etc.
  end
  </code></pre>
  
  <p>which gives me the correct routing.  Everything works, but the annoying thing is that all my path helpers have the '/cs1337' prefix, which is unnecessary since the <code>.htaccess</code> rewrite rules add it back in.  For example,</p>
  
  <pre><code>login_path # =&gt; /cs1337/login
  </code></pre>
  
  <p>when only</p>
  
  <pre><code>login_path # =&gt; /login
  </code></pre>
  
  <p>is necessary.</p>
  
  <p>I would like to override all of the path helpers to strip off the prefix, using something like</p>
  
  <pre><code>def &lt;override all path helpers&gt; 
    path = super
    path.gsub(%r{^/cs1337}, '')
  end
  </code></pre>
  
  <p>I know the path helpers are dynamically generated, but I can't figure out where start ... I can't even find what module the path helpers are generated in.</p>
  
  <p>Thanks for any help you can offer!</p>