title: How to set the Referer header before loading a page with Ruby mechanize?
body: <p>Is there a straightforward way to set custom headers with Mechanize 2.3?</p>
  
  <p>I tried a <a href="https://stackoverflow.com/a/1536251/1069375">former solution</a> but get:</p>
  
  <pre><code>$agent = Mechanize.new
  $agent.pre_connect_hooks &lt;&lt; lambda { |p|
    p[:request]['Referer'] = 'https://wwws.mysite.com/cgi-bin/apps/Main'
  } 
  
  # ./mech.rb:30:in `&lt;main&gt;': undefined method `pre_connect_hooks' for nil:NilClass (NoMethodError)
  </code></pre>