I am using Rails tutorial with example book by Michael Hartl as a reference for this question.
Here i am using rails 3.1.3 . What is the best way to use Named Routes
routes.rb
root :to => "pages#home"
match '/contact', :to => 'pages#contact'
match '/about', :to => 'pages#about'
match '/help', :to => 'pages#help'
When I access these routes from a view using about I find no error but when I am access it by “about_path” I get an error. But in the book they use about_path. Have the concept of named routes changed in rails 3.1 ?
<li><%= link_to "About", '*about*' %></li>
<li><%= link_to "Contact", 'contact' %></li>
<li><%= link_to "Home", 'root_path' %></li>
If i use “about_path” in the above code I get an error ‘route not found’
Question 1. What is the best way to use named routes inside the views? (Best way means I only need to change the route path at single place )
Question 2. How can i access root with concept of named routes?
(I get an error message when i try to access it using ‘root_path’).
Accessing Named routes from views
Routes