title: Adding a record's attribute to the URL before the ID
body: <p>I'm trying to add a specific attribute of a record in Rails to the URL from something like:</p>
  
  <pre><code>domain.com/share/5
  </code></pre>
  
  <p>(where <code>5</code> is the record ID) to something like:</p>
  
  <pre><code>domain.com/share/johnsmith/5
  </code></pre>
  
  <p>where <code>johnsmith</code> is stored in record <code>5</code>. I'm alternating between these two routes to no success:</p>
  
  <pre><code>get "/share/:name/:id" =&gt; "share#show"
  resources :share, :only =&gt; [:show]
  </code></pre>
  
  <p>And between these two methods:</p>
  
  <pre><code>share_path(doc.user.name, doc)
  share_path(doc)
  </code></pre>
  
  <p>The show method in the <code>ShareController</code> is pretty standard.</p>
  
  <hr>
  
  <p><strong>The problem:</strong></p>
  
  <p>Using <code>share_path(doc.user.name, doc)</code> in the view generates a link to <code>/share/johnsmith.5</code>, instead of <code>/share/johnsmith/5</code>.</p>