Base URL of Rails app in Model
If you want to get the root URL in your model, what I did is call an ENV variable.
If you haven't already, go ahead and create .env in the root directory of your applicatoin and set in development to:
ROOT_URL=http://localhost
In your production environment set:
ROOT_URL=https://mydomain.com
Of course this is hard coded so the pitfall is that you need to remember to change this when changing domains and each environment's file must be different.
And be sure this is also in your gitignore since other sensitive data will be stored here.
In your model you call by: ENV['ROOT_URL']
You may use environment variables:
in environment
ROOT_URL=http://myapp.com
in-app
ENV['ROOT_URL']