Simple link_to by root_url

I have a very simple view of link_to the problem there is no error message, just a weird dot in the URL "http://0.0.0.0{000/.Hire" do not know why the dot is between the root URL and Hire?

link_to:

<%= link_to page.name, root_url(page.name) %> 

The routes are great if I type manually: http://0.0.0.0:3000/Hire {000/Hire I got to the right page, but link_to just makes a mistake.

I would be grateful for any help.

Thank you very much

Dan

+4
source share
1 answer

root_url should not be provided with this type of parameter. It is logical that it does not work.

Run rake_routes in the console to get the correct names for your routes.

One ugly workaround that fits your needs would be:

 <%= link_to page.name, root_url + page.name %> 

Last question: why are you using root_url instead of root_path ?

The former tend to uselessly pollute their views.

+15
source

All Articles