title: Rails 3 Route Wildcards
body: <p>I am currently setting up routes in a Rails 3 application, and would appreciate it if someone could point me in the right direction.</p>
  
  <p>Essentially, I am setting up some routes to provide data for some chained dropdowns, and would like to be able to have routes like:</p>
  
  <pre><code>/vehicles/trims/01299999
  /vehicles/trims/02299999
  </code></pre>
  
  <p>Where 01299999 and 02299999 are ids for two different parameters (in this case lets say 01299999 loads :vehicle_make into the params and 02299999 is :fuel_type in the params). I'm aware that I can ensure they get routed to the correct controller action and load the correct params by using constraints.</p>
  
  <p>What makes this complicated, however, is that I would like to be able to have more than one option specified in the url, in any order, e.g.:</p>
  
  <pre><code>/vehicles/trims/01299999/02299999
  </code></pre>
  
  <p>or</p>
  
  <pre><code>/vehicles/trims/02299999/01299999
  </code></pre>
  
  <p>and these would load the correct params based on the structure of the id number (so if it starts with '012' it should always be :vehicle_make and if it starts '022' it should always be :fuel_type. How can I do this?</p>
  
  <p>As a side note, it would be great if anyone could indicate how to constrain the id column for my models, so that when a vehicle make is created, its id should always start 012 and so on.</p>
  
  <p>Thanks for any assistance!</p>