title: How to pass params to a block in Rails routes?
body: <p>I am using Rails 3. And I'm wondering how to pass params to some blocks in <code>routes.rb</code>.</p>
  
  <p>What I'm trying to do is to make a <code>catch all</code> route, that check from <code>slugs</code> database the model name of it by the id.</p>
  
  <p>After getting the <code>model name</code> i pluralize it to get the controller name.</p>
  
  <pre><code>match '/:id', :controller =&gt; proc { Slug.find_by_iid(params[:id]).model.pluralize }, :action =&gt; :show
  </code></pre>
  
  <p>The table <code>slugs</code></p>
  
  <pre><code>model    iid
  -----    -----
  post     4d2c7de0c5abe7f8a9000007
  item     4d2c7de0c5abe7f809000004
  </code></pre>
  
  <p>When I try to access some pages like <code>/4d2c7de0c5abe7f8a9000007</code> I got this error:</p>
  
  <pre><code>Started GET "/4d2c7de0c5abe7f8a9000007" for
  127.0.0.1 at 2011-01-12 00:04:31 +0200
  
  ActionController::RoutingError (wrong constant name #&lt;Proc:0x0000010337c310@):
  
  Rendered /Users/amr/.rvm/gems/ruby-1.9.2-p136@rails3/gems/actionpack-3.0.3/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (1.2ms)
  </code></pre>
  
  <p><strong>The expected is to point to posts#view with iid: 4d2c7de0c5abe7f8a9000007</strong></p>