title: Rails: How to get match method options from within view helpers and controllers?
body: <p>There is a <a href="http://api.rubyonrails.org/classes/ActionDispatch/Routing/Mapper/Base.html#method-i-match" rel="nofollow">match</a> method in Rails dedicated to set routes. It has a few options: <code>:controller</code>, <code>:action</code>, <code>:via</code>, etc. One of them is <code>:as</code> option.</p>
  
  <blockquote>
    <p>:as </p>
    
    <p>The name used to generate routing helpers.</p>
  </blockquote>
  
  <p>For example, I have such a route setting:</p>
  
  <pre><code>match("user/hello' =&gt; "users#show",
        via: 'get',
        :as =&gt; :user_hello,
      )
  </code></pre>
  
  <p>This <code>:as</code> option lets me do this in my <code>html.erb</code> template:</p>
  
  <pre><code>&lt;%= link_to("User Hello", user_hello_path()) %&gt;
  </code></pre>
  
  <p>and I get this in my rendered page:</p>
  
  <pre><code>&lt;a href="user/hello"&gt;User Hello&lt;/a&gt;
  </code></pre>
  
  <p>But I'd like to change the default behavior of this helper. I want to add some prefix to the generated url, to have it like this one:</p>
  
  <pre><code>&lt;a href="myprefix/user/hello"&gt;User Hello&lt;/a&gt;
  </code></pre>
  
  <p>The question is, how to get that <code>:as</code> variable in my helper module file:</p>
  
  <pre><code># File: C:\MyApp\app\helpers\users_helper.rb
  module UsersHelper
  
      # I explicitly redefine the default helper
      # but can't get :as option here
      def user_hello_path
          "myprefix/" + :as.to_s  # &lt;-- how to get the ":as" option here
      end
  end
  </code></pre>
  
  <p>Also how to get all those <code>match</code> method options in controllers?</p>