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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:06:38+00:00 2026-06-01T15:06:38+00:00

These are the relevant models: class Repository < ActiveRecord::Base has_many :quizzes, :dependent => :destroy

  • 0

These are the relevant models:

class Repository < ActiveRecord::Base
   has_many :quizzes, :dependent => :destroy
   has_one :key, :dependent => :destroy

   accepts_nested_attributes_for :key, :quizzes
end

class Quiz < ActiveRecord::Base
   belongs_to :repository
   has_many :topics, :dependent => :destroy

   accepts_nested_attributes_for :topics
end

This is in my routes:

GqAPI::Application.routes.draw do
  resources :repositories do
    resources :quizzes
  end

  resources :quizzes

  resources :keys

  resources :topics

  resources :questions
end

When I try this configuration I get all the quizzes in the database, not just the ones for the ID I specify when I try to go to /repositories/1/quizzes

Any ideas on why? Thanks so much for your time

  • 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-01T15:06:39+00:00Added an answer on June 1, 2026 at 3:06 pm

    In the index action of your QuizzesController you need to add:

    def index
      @repository = Repository.find(params[:repository_id])
      @quizzes = @repository.quizzes
    end
    

    The @repository line will find the repository based on the parameter in your URL. Then it will find all of the quizzes based on that repository.

    Then in your view, you can loop through all of those quizzes when you display them.

    Note

    The way you currently have your routes setup, you have the ability to access a page at /quizzes but it sounds like you have no desire for this. If this is the case, you can remove resources: quizzes from your routes.rb (the second one only, not the nested one).

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

Sidebar

Related Questions

class PollOption < ActiveRecord::Base belongs_to :poll has_one :address end class Address < ActiveRecord::Base belongs_to
Is there any way to use ActiveRecord calculations while also acquiring relevant field names?
these are my entities (simplified): public class IdentificationRequest { private int id; private ICollection<IdentificationRequestStateHistoryItem>
These functions may be hard to fit into a specific class, what's the best
For Django 1.1. I have this in my models.py: class User(models.Model): created = models.DateTimeField(auto_now_add=True)
Alright, I have a fairly simple design. class Update(models.Model): pub_date = models.DateField() title =
Having difficulty finding relevant search results... Given this model: public abstract class A {
I have a Django model with a Person model: class Person(models.Model): # Personal details
I am working with models of neurons. One class I am designing is a
Imagine a model like this: class CFile(models.Model): filepath = models.FileField(upload_to=...) collection = models.ForeignKey(FileCollection,null=True) ...

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.