Ask A Question

Notifications

You’re not receiving notifications from this thread.

I'm not sure what's the correct title for my question is. Read the content for more information.

Dexter Small asked in General

I am new to rails and to learn i'm creating a simple school system. In the system, there are subjects, teachers, students, forms (which are bascially grades eg. grade 1, 2...) and streams (A, B, or C). My subject and streams have a many to many association and the form and streams have a many to many association also.

For the subject creation, users enter the subject name, assign a teacher and select the streams the subject is taught in. My issue is that the streams show up but I want them to be displayed in an orderly manner according to the form they are assgined to.

Kinda like this:

Please Select the streams the subject is taught in

Form 1 streams
- A
- B
- C
Form 2 streams
- A
- B
-C

Currenrtly it shows up like this

Please Select the streams the subject is taught in

  • A
  • B
  • C
  • A
  • B
  • C

All my associations is in order it's just this I cant wrap my head around, I am using simple_form, here is the snipet of code I have.
<%= f.association :streams, as: :check_boxes, label: "Assign streams to this subject" %>

Thank you, for the help.

Reply

Post your whole form code if possible.

Reply

<%= simple_form_for(@subject) do |f| %>
<%= f.error_notification %>
<%= f.error_notification message: f.object.errors[:base].to_sentence if f.object.errors[:base].present? %>


<%= f.input :name %>
<%= f.association :teacher, label: "Assign a teacher to this subject", hint: "More than one teachers can be assigned to a subject", prompt: "Select teacher", :label_method => lambda { |teacher| teacher.fname + " " + teacher.lname } %>
<%= f.association :streams, as: :check_boxes, label: "Assign sets to this subject" %>


<%= f.button :submit %>

<% end %>

Reply

nice

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 82,464+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.