Accessing the router outside of the controller context can be a real pain especially if you need access to _url
helpers. It is even more difficult if you want to pass the router as an argument to a method or class. We had come up with a few different solutions but so far this has been the most reliable.
ENV['SOME_URL'] = 'http://my.url.com'
class MyClassThatHasAccessToRoutes