You are in right place if you want to get root url along with port number in rails.
Code that works
This can be achieved by either
In applications you may need to generate url that will link back to your application while sending email.
Problems it has solved:
Previously, we used to have environment variable like
HOST: localhost:3000 saved in
application.yml which would be later called by
This would lead to error when I would run server in some other port than default(3000).