title: How to parse a locally running URL with Mechanize
body: <p>I am just playing with Mechanize because I am attending a workshop on Rails security next week and have encountered a difficulty.</p>
  
  <p>If I use this code:</p>
  
  <pre><code>agent = Mechanize.new
  uri = URI 'http://www.bbc.co.uk/news/uk-39351833'
  page = agent.get uri
  </code></pre>
  
  <p>then the page URL is returned correctly as:</p>
  
  <pre><code>{url #&lt;URI::HTTP http://www.bbc.co.uk/news/uk-39351833&gt;}
  </code></pre>
  
  <p>and I can then parse the page. However, I have to use Mechanize against locally installed Rails apps for workshop exercises, and hit a stumbling block.</p>
  
  <p>When I run this code:</p>
  
  <pre><code>agent = Mechanize.new
  uri = URI 'http://localhost:3000/secrets/1237'
  page = agent.get uri
  </code></pre>
  
  <p>and inspect the page, the URL is now:</p>
  
  <pre><code>{url #&lt;URI::HTTP http://localhost:3000/&gt;}
  </code></pre>
  
  <p>It has not kept the '1237' from the end of the path. This is just the root page of the app. </p>
  
  <p>What am I missing?</p>