Skip to main content
Ask A Question
Notifications
You’re not receiving notifications from this thread.
Subscribe

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

General • Asked by Dexter Small

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.


Post your whole form code if possible.


<%= 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 %>

Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 31,152+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.