MrThomas
MrThomas

Reputation: 427

Simple link_to from root_url

I have a very simple view link_to problem no error message just a strange dot in url "http://0.0.0.0:3000/.Hire" not sure why the dot is there between the root url and Hire?

link_to:

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

The routes are fine if I type manually: http://0.0.0.0:3000/Hire I get taken to the right page but the link_to is just wrong.

I would be grateful for any help.

Many thanks

Dan

Upvotes: 4

Views: 8223

Answers (1)

apneadiving
apneadiving

Reputation: 115521

root_url isn't supposed to be given this kind of parameters. It's logic it's failing.

Run rake_routes in your console to get the proper names of your routes.

One ugly workaround to fit your needs would be:

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

One last question: why do you use root_url instead of root_path?

The former tend to uselessly pollute the views.

Upvotes: 15

Related Questions