title: Routes with multiple, optional, and pretty parameters
body: <p>I have a situation where I'm in need to constructing pretty url paths.</p>
  
  <p>I have a FilesController that need to handle URLs like:</p>
  
  <pre><code>mydomain.com/files/path/dir1/dir2/user/bob
  mydomain.com/files/path/dir1/user/bob
  mydomain.com/files/path/dir1
  mydomain.com/files/user/bob
  </code></pre>
  
  <p>In the controller, I want <code>params[:path]</code> to contain everything between <code>/path</code> and <code>/user</code> and <code>params[:user]</code> to contain anything after <code>/user</code> (assuming only one user and it's optional).</p>
  
  <p>I'm looking for the best way to do this, preferable with just one statement in the <code>routes.rb</code> file. The trickiest part, I think, is that after <code>/path</code> an actual path to a file might be provided, N times deep.</p>