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 7810651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T03:51:34+00:00 2026-06-02T03:51:34+00:00

Using Rails 3.1.1 and the gem acts_as_tree. I have googled the issue and checked

  • 0

Using Rails 3.1.1 and the gem acts_as_tree. I have googled the issue and checked similar questions here at SO (the answers are too old, or irrelevant).

I have a model called articles with a route that today looks like:

  resources :articles, :path => '', :only => :show 
  resources :articles, :path => 'articles', :except => :show

I have three articles: “book”, “chapter1” and “chapter2”. Where book is parent to chapter1 and chapter2.

Today, my path to each article is: host.com/book, host.com/chapter1 and host.com/chapter2. I want the url path to be host.com/book/chapter1 and host.com/book/chapter2 , i.e. nested routes.

How can I create this in a clean simple manner?

Basically, I want a path that will be host.com/:parent_id/:parent_id/:id with N numbers of :parent_id. Pretty much how WordPress-articles are routed.

I don’t believe route globbers is the solution, but I might be wrong. It seems to give the same result for host.com/:id and host.com/foo/bar/:id which will result in duplicate content.

  • 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-06-02T03:51:36+00:00Added an answer on June 2, 2026 at 3:51 am

    A)

    If you have a solution for the routing and the only problem with it is that you’re concerned about duplicate content issues, you could consider adding <link rel="canonical" href="..."> to the pages generated from those requests. It’s not bulletproof though, as Google considers it a suggestion.

    Not sure if the route globbers solution would take care of generating the URLs with parent IDs though.

    B)

    You don’t need the parent IDs to perform the routing, correct? You just want to include them in the URLs and route those requests the same as if using the URLs like example.com/chapter1, correct?

    If you’d consider a solution that’s not purely at the Rails level, what about rewriting the URLs on those requests so that /:parent_id/:parent_id/:id becomes /:id before Rails processes it? That would be easier if there was a static prefix, like /articles/:parent_id/:parent_id/:id.

    I imagine you’d need to write some helpers to generate the URLs with parent IDs for linking to those resources.

    Duplicate Content

    Either way, you’ll need to generate URLs that include the parent IDs, so duplicate content issues probably aren’t too likely if you only link to those resources using those URLs.

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

Sidebar

Related Questions

I'm using Rails. I just installed the backbone-rails gem and followed the instructions here
Note: Using Rails 3.1 and current delayed_job gem. I have a User model that
I have been using the less-rails-bootstrap gem from https://github.com/metaskills/less-rails-bootstrap in my rails 3.1 project.
i am working on rails 3 and using acts_as_taggable_on gem I have blog,Article associated
I am using Rails 3.2 and the twitter-bootsrap-rails gem (link) . I have a
I'm using Rails 3.0 and the acts_as_taggable_on gem. I have a Candy model and
I'm using rails-rspec gem and I have several specs (models, controllers, etc). When I
Rather than using the latest Rails gem for my application, I like to have
I'm using acts-as-messageable , a rails gem, in an app i have. However in
I am using rails 3.2.3 and gmaps4rails gem. I have one model called contact.

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.