Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 319
MrThomas Avatar asked Dec 06 '22 20:12

MrThomas


1 Answers

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.

like image 152
apneadiving Avatar answered Jan 01 '23 06:01

apneadiving