Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7003631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:05:39+00:00 2026-05-27T21:05:39+00:00

I am using Rails tutorial with example book by Michael Hartl as a reference

  • 0

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’).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T21:05:40+00:00Added an answer on May 27, 2026 at 9:05 pm
    JP:guard2 jayparteek$ rake routes
       root  /                  {:controller=>"pages", :action=>"home"}
    contact  /contact(.:format) {:controller=>"pages", :action=>"contact"}
      about  /about(.:format)   {:controller=>"pages", :action=>"about"}
       help  /help(.:format)    {:controller=>"pages", :action=>"help"}
    

    Accessing Named routes from views

        <li><%= link_to "About", 'about' %></li>
            <li><%= link_to "Contact", 'contact' %></li>
            <li><%= link_to "News-Home", '/' %></li>
    

    Routes

      match '/contact' => 'pages#contact' 
      match '/about' => 'pages#about'      
      match '/help' => 'pages#help' 
    
      root :to => "pages#home"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am practicing this RoR tutorial project of Michael Hartl: http://ruby.railstutorial.org/ruby-on-rails-tutorial-book I am using
I am using Rails 3.1 and have been using this railscast tutorial to implement
I am trying to use PDFKit using rails 3, I followed the railscast tutorial
I am using Rails Carrier Wave with JQuery Upload like on this rails tutorial
I'm working through Michael Hartl's Ruby on Rails tutorial on http://ruby.railstutorial.org . I'm having
I'm following Michael Hartl's Rails Tutorial, and for some reason the following code: <%=
Hello friends i need a book/ tutorials for rails without using scoffold. All the
I'm using rails 2.3.5 with i18n. I's there a way to find all not
I'm following the ruby on rails tutorial: http://railstutorial.org/chapters/static-pages#top I'm up to using rspec. Having
Hi trying to make a Registration page with Ruby on rails using the tutorial

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.