At first I agree with zed. This should not be done in the model. Your models do not need to know about the http address.
I do the same in resque work. That's what I'm doing:
include ActionDispatch::Routing::UrlFor
include ActionController::PolymorphicRoutes
include Rails.application.routes.url_helpers
default_url_options[:host] = 'example.com'
Then you can call any regular url generator.
url_for(object)
page_url(object)
It will create a link on the node defined as default_url_options[:host]
source
share