title: How to use url helpers in lib modules, and set host for multiple environments
body: <p>In a Rails 3.2 app I need to access url_helpers in a <code>lib</code> file. I'm using</p>
  
  <pre><code>Rails.application.routes.url_helpers.model_url(model)
  </code></pre>
  
  <p>but I'm getting</p>
  
  <pre><code>ArgumentError (Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true):
  </code></pre>
  
  <p>I've found a few things written about this, but nothing that really explains how to solve this for multiple environments.</p>
  
  <p>i.e. I assume I need to add something to my development.rb and production.rb files, but what?</p>
  
  <p>Closest I've seen to an answer suggested using <code>config.action_mailer.default_url_option</code>, but this does not work outside of action mailer.</p>
  
  <p>What is the correct way to set the host for multiple environments?</p>