Get Rails base URL if not in controller

990 views Asked by At

In controller a base URL could be got using request object, but my process is a worker thread started from initializer, and it doesn't have access to request.

1

There are 1 answers

0
joshua.paling On BEST ANSWER

If you don't have a request (which you don't, in the context of a background worker), then you can't tell the URL automatically and the only way is to set it explicitly. You could set it as an environment variable, or set it as a constant in an initializer, and then get it from there.