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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T23:12:05+00:00 2026-06-04T23:12:05+00:00

I am trying to find a way to pull all notes that are assigned

  • 0

I am trying to find a way to pull all notes that are assigned to a course but only when necessary. I have a show page which shows all of the notes for a quiz.

course show.html.erb

<%= @course.name %>
<% @quiz.notes.each do |note| %>
    <%= link_to note.title, quiz_note_path(@quiz, note)  %><br/>
<% end %>

The above code works find except it pulls all of the notes and not the notes that are assigned to that course. How can I tell rails to only pull the note if note and course name are equal?

update!

In the note new.html.erb I have am using collection_select

  <%= f.collection_select(:course_ids, @quiz.courses, :id, :note_name, options = {:prompt => "Choose"}) %>
  • 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-04T23:12:07+00:00Added an answer on June 4, 2026 at 11:12 pm

    It seems like you don’t have relationship between course and quiz.

    A course has many quizzes, a quiz has many notes. You should setup your relationship this way, so it won’t pull out unnecessary notes that are not related to the current course.

    The trick here is to pull all notes inside a course by using has_many :through.

    class Course < ActiveRecord::Base
      has_many :quizzes
      has_many :notes, :through => quizzes
    end
    
    class Quiz < ActiveRecord::Base
      has_many :notes
    end
    
    class Note < ActiveRecord::Base
      belongs_to :quiz
    end
    
    <%= @course.name %>
    <% @course.notes.each do |note| %>
        <%= link_to note.title, quiz_note_path(note.quiz, note)  %><br/>
    <% end %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to find a way to locate all geometry that intersects a given
I'm trying to find a way with VBA to hide/show a certain text-style. What's
I am trying to pull plaintext between <p> tags but only if between span
I am trying to find a way to pull 10 random records and then
Im trying to find a way to enable HTML Tags in PHPBB (only for
Trying to find a way to send a POST HTTPS request from Python to
Struggling trying to find best way to reverse a GUID to username. Any help?
I'm trying to find a way to detect when a flash drive has been
I'm trying to find a way to negate sentences based on POS-tagging. Please consider:
I am trying to find a way of center aligning a block containing an

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.