In my Ruby on Rails 3.1 app I have a link like this:
<%= link_to 'Home', root_url %>
On My dev. machine it renders a link with “localhost:3000”. On production it renders a link with an IP Address like this “83.112.12.27:8080”. I would like to force rails to render the domain address instead of the IP Address. How can I set root_url?
In your routes set:
and in your links set:
It will render
So in your localhost It’d take you to
http://localhost:3000/and in your production server It’d take you to
http://yourdomian.com/and the
routes.rbwill render theindexaction of the controllerwelcomeby default.PS. you also need to remove
index.htmlfrompublicdirectory in order to use this.UPDATE
A little bit more on routing:
Rails Routing from the Outside In