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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T02:02:47+00:00 2026-06-07T02:02:47+00:00

Helo, I had stuck with this problem. Just to make things simple i’ll explain

  • 0

Helo, I had stuck with this problem.
Just to make things simple i’ll explain it shorter.

Student has_many   :grades
        belongs_to :class

Grade belongs_to   :student
      belongs_to   :rubric

Rubric belongs_to  :course
       has_many    :students, :through => :class

To create new grade we need to find existent students. We can call @class.students to do so. Also, grade should be created with rubric_id.

I’ve already found out how to do nested forms. But how to pass plural student id’s to new grades?

How to build controller and view to do so?

  • 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-07T02:02:48+00:00Added an answer on June 7, 2026 at 2:02 am

    (Arg, I can’t format my question properly in the comments, so I have to use an answer. Bear with me please because I don’t think it answers your question yet.)

    I don’t think your model is setup properly to achieve that. In the scenario you are asking, Student and Grade seems to be in many-to-many association. I.e. a student has many rubric, but a rubric has many students, both through grade (which is your association model). Did I understand this correct?

    Class   has_many   :students
            has_many   :grades
            has_many   :rubrics, :through => :grade
    
    Student has_many   :grades
            has_many   :rubrics, :through => :grade
            belongs_to :class
    
    # A grade is a particular rubric assigned to a student for a particular class
    Grade belongs_to   :student 
          belongs_to   :rubric
          belongs_to   :class
    
    Rubric belongs_to  :course
           has_many    :grades
           has_many    :students, :through => :grade
    

    Let me know if my interpretation above is correct and I can follow up with an answer on the controller and the view. I recently did something very similar for another project.

    EDIT: Now that we have clarified the problem, here’s my suggested answer.
    The goal is to assign multiple students for a rubric in a particular class.

    There is no built-in methods that will support something like this so we will have to build the records and the association with the right controller action and form.

    In Grades model we add this function:
    def self.checked?(class_id, student_id, rubric_id)
    Grade.find(:all, :conditions => {:class_id => class_id, :student_id => student_id, :rubric_id => rubric_id}).present?
    end

    In the form_for :rubric, we create something like this:

    <%= form_for @rubric do |f| %>
      <% for @class.students.each do |student| %>
      <%= fields_for :grades do |builder| %>
        <%= check_box_tag "grades[" + @class.id.to_s + "][]", rubric.id, Grade.checked?(@class.id, student.id, @rubric.id) %>
      <% end %>
      <%= f.submit "Save" %>
    <% end %> 
    

    Now in the RubricsController’s create action you should have a params[:grades] which is a hash with key [:class] whose value is should just be an array of student ids. Now you can create the grades object that associates these models since you have a rubric id (@rubric.id), a class id (@class.id) and an array of student ids.

    I hope I didn’t screw the code above since I had to change it from my current implementation. But looking at the console log of the rails server should allow you to figure out what parameters are passed when the above form is submitted and make adjustments.

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

Sidebar

Related Questions

What am I doing wrong here: class Helo { // main: generate some simple
Helo, there are 3 files, CustomerClient.java , CustomerServer.java and Customer.java PROBLEM: In the CustomerServer.java
I have a problem running RoR project. I am getting this error while running
Helo everyone I've create simple page with table and would like populate it with
Helo! Is this possible to use string value of one node which tells what
helo everyone This is a code from a book i have bought. It gives
helo I know this may be easy but believe me I didn't understud it
Helo everyone! I have this live wallpaper in witch I try to show a
Given this text file: Received: from unknown (HELO aws-bacon-delivery-svc-iad-1007.vdc.g.com) ([10.146.157.151]) by na-mm-outgoing-6102-bacon.iad6.g.com with ESMTP;
Helo Can anybody explain me how to get configuration element from .config file. I

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.