I am trying to use Rails routes outside of Rally commons classes such as controllers, views, and even models. I managed to get it to work with this code:
class SomeService include Rails.application.routes.url_helpers default_url_options[:host] = 'localhost' def myMethod my_resource_url(:id => 1) end end
SomeService # myMethod works as expected in my test classes, returning the URL: http: // localhost / myresource / 1
But when I start the rails server, I cannot get the actual host and port. How can i solve this?
source share