title: How to modify (encode and decode) routes id, but without changes in the model or controller?
body: <p>I want to expose my database ids and encode/decode the id with routes helper. For encoding I use <a href="https://github.com/peterhellberg/hashids.rb" rel="nofollow">Hashids</a> gem.</p>
  
  <p>Now I have:</p>
  
  <p>routes.rb</p>
  
  <pre><code>get 'companies/:id/:year', to: 'company#show', as: 'companies'
  </code></pre>
  
  <p>company url:</p>
  
  <pre><code>/companies/1/2015
  </code></pre>
  
  <p>For id encoding I have encode/decode helper methods:</p>
  
  <pre><code>def encode(id)
     # encode...
     return 'ABC123'
  end
  
  def decode(hashid)
     # decode...
     return 1
  end
  </code></pre>
  
  <p>How I can implemented, that id will be with routes helper converted?
  So must show the URL:</p>
  
  <pre><code>/companies/ABC123/2015
  </code></pre>
  
  <p>and controller must get automatically params with id 1.</p>