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

  • SEARCH
  • Home
  • 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 6623183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:30:10+00:00 2026-05-25T21:30:10+00:00

New to ruby on rails, trying to get this url structure: /about /about/staff /about/contact

  • 0

New to ruby on rails, trying to get this url structure:

/about
/about/staff
/about/contact
/about/brazil
/about/brazil/staff
/about/brazil/contact

When I do:

rails generate controller about index
rails generate controller about staff
rails generate controller about contact

I set my routes to:

get "about", :to => "about#index"
get "about/staff", :to => "about#staff"
get "about/contact", :to => "about#contact"

And all is well, but I got stumped when I need to do the same for a third level for the brazil office

Should I just do

rails generate controller about brazil_index
rails generate controller about brazil_staff
rails generate controller about brazil_contact

get "about/brazil", :to => "about#brazil_index"
get "about/brazil/staff", :to => "about#brazil_staff"
get "about/brazil/contact", :to => "about#brazil_contact"

Or is there a cleaner way to accomplish this?

  • 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-25T21:30:11+00:00Added an answer on May 25, 2026 at 9:30 pm

    I think you want to call this rails generate controller About index staff contact

    to generate AboutController with three actions index, staff and contact. Then you want to allow passing in id parameter as the second path element:

    Then in config/routes.rb:

      get "about/index"
      get "about/staff"
      get "about/contact"
      get "about/:id/index" => 'about#index'
      get "about/:id/staff" => 'about#staff'
      get "about/:id/contact" => 'about#contact'
    

    When I check routes with rake routes I see now:

    $ rake routes
      about_index GET /about/index(.:format)       {:controller=>"about", :action=>"index"}
      about_staff GET /about/staff(.:format)       {:controller=>"about", :action=>"staff"}
    about_contact GET /about/contact(.:format)     {:controller=>"about", :action=>"contact"}
                  GET /about/:id/index(.:format)   {:controller=>"about", :action=>"index"}
                  GET /about/:id/staff(.:format)   {:controller=>"about", :action=>"staff"}
                  GET /about/:id/contact(.:format) {:controller=>"about", :action=>"contact"}
    

    You can now request http://localhost:3000/about/brazil/staff and the value of params[:id] will be “brazil”.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get Ruby on Rails setup on my new eeeubuntu install and
I am new to Ruby on Rails and I'm desperately trying to get a
Still can't get this working...Rails 3.1.3, Ruby 1.9.2 on Heroku's Cedar Stack. Trying to
I'm new to Ruby on Rails, trying to get my first app working, which
New to rails/ruby (using rails 3 and ruby 1.9.2), and am trying to get
I'm new to Ruby on Rails and I'm trying to model my table relationships.
I'm new to Ruby on Rails, and I'm trying to create a bass guitar
I am new to Ruby on Rails and I'm trying to go through a
I'm trying my best to get Ruby on Rails installed on Ubuntu 11.04. I
I'm new to Ruby on Rails. I'm trying to install rails on an ubuntu

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.