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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:50:04+00:00 2026-06-13T13:50:04+00:00

I am using Rails 3.2 and am attempting to make a scoped nested resource

  • 0

I am using Rails 3.2 and am attempting to make a scoped nested resource (not sure if this is the right terminology). I have several groups and I want each group to have its own set of pages, like so:

/groups/1/pages/1
/groups/1/pages/2
/groups/1/pages/3
/groups/2/pages/1
/groups/2/pages/2
/groups/3/pages/1
/groups/3/pages/2
/groups/4/pages/1
etc.

First I created a groups controller and a pages controller and nested them like

resources :groups do
  resources :pages
end

The problem I was having is that I could see group 1’s pages from groups 2, 3, and 4 by changing the :group_id in the URL. Also, the page ids were unique across all groups, not just limited to a single group.

Next I tried making a nested controller by doing rails g controller groups/pages index show new create edit update destroy but I was also unable to get this to work. I do not know enough Rails terminology to figure out what to Google.

  • 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-13T13:50:05+00:00Added an answer on June 13, 2026 at 1:50 pm

    What I think you are trying to accomplish is associations. And instead of generating controllers, you should probably generate scaffolds (which includes a model, controller, and default views). At the very least, you will need group and page models.

    Then add has_many :pages in your group model. And add belongs_to :group in your page model. Then you need to add a group_id column to your page model/database.

    However, if I’m wrong and all you are trying to do is paginate groups, then use the will_paginate gem.

    I would also suggest you go through Mike Hartl’s tutorial. It will give you a great background and you will learn rails terminology and basic techniques.

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

Sidebar

Related Questions

Using Rails 3.2.2 and ruby 1.9.2 and I am not able to serve assets
Using Rails 3.2. I have an individual Shop post, and each shop has reviews.
Using Rails 3.1.3 with Ruby 1.9.3p0. I've discovered that by default, Rails does not
I'm attempting to get my first hello world rails example going using the rails'
I am attempting to create an API with Rails using BDD with RSpec. Rails
I'm using gvim and rails.vim and getting the following error when attempting to run
I'm attempting to deploy my rails application w/ puma using Capistrano. Towards the end
I am using Capistrano to deploy a ruby on rails project. I am attempting
I'm using Active Record outside of rails and I have two AR classes similar
I am attempting to remotely connect to a MySQL database using ruby on rails.

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.