title: Rails, getting a part of a URL /modelstuff/31 --- how to get 31?
body: <p>I'm interested in learning in Rails 3, how to grab the URL with something like <code>params[:urlpath]</code></p>
  
  <p>and then indexing it with / </p>
  
  <p>so if I had a url like examples:</p>
  
  <pre><code>/books/1
  /books/1/authors/3
  /books/1/authors/3/chapters
  /books/1/authors/3/chapters/33
  </code></pre>
  
  <p>I could always obtain 1</p>
  
  <p>something like <code>params[:urlpath] index[2]</code></p>
  
  <p>I need this to populate the following which is happening on the page:</p>
  
  <pre><code>$.ajax({
      url: '/nav/sidenav',
      data: "urlpath=" + urlpath
  });
  </code></pre>
  
  <p>ideas? thxs</p>