In a Rails 3.2 app I need to access url_helpers in a lib file. I'm using Rails.application.routes.url_helpers.model_url(model) but I'm getting ArgumentError (Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true): I've found a few things written about this, but nothing that really explains how to solve this for multiple environments.