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.
i.e. I assume I need to add something to my development.rb and production.rb files, but what?
Closest I've seen to an answer suggested using config.action_mailer.default_url_option
, but this does not work outside of action mailer.
What is the correct way to set the host for multiple environments?