user1946705
user1946705

Reputation: 2888

rails 3 routing to root my app

I my root url of my app is home/index, but if I'll click on link for root of my app, I have in body of that link :controller => 'home', :action => 'home' - and that means, that after click on this link I'll redirect to root and url address I'll have myapp.com/home/index. And I would like to have there only myapp.com.

I am looking to solution and I found root_url -- but if I'll use this helper,

<%= link_to 'Back to root', :root_url %>

I'll get an error undefined method `root_url_path' -- I would like to ask you, how is possible to define this helper, what everything is need for using this helper?

Thank you and nice a rest of weekend :)

Upvotes: 1

Views: 2973

Answers (2)

Neovibrant
Neovibrant

Reputation: 757

You're almost there, though it's not :root_url, just :root

<%= link_to 'Back to root', :root %>

Upvotes: 2

Jits
Jits

Reputation: 9728

Try:

<%= link_to 'Back to root', root_url %>

... root_url should be a method call and not a symbol

Upvotes: 6

Related Questions