0

Say I have a form for entering subject marks (separate model) and I want to enter marks for students from a specific classroom from a select box. How do I upload all students based on the classroom I select and have them line up next to marks field

Classroom > One

Student Name - Mark

Steve Wonder - _______

Roman Reigns - _______

Banana Mike - _______

Rona Meakins - _______

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
Sawo Cliff
  • 2,888
  • 1
  • 17
  • 21

1 Answers1

0

There are many ways to solve this. I'll go with the simplest one and let's say you use simple form.

What you basically want to do is something like this:

form_for @class do |f|
 # Here you can either loop trough the number of students here or make JS method call from a button to create a new instance of the div below for each student you want to add
  f.simple_fields_for :students do |student_form|
    # Here you have all simple_form methods available
    student_form.input :score
  end
  f.button :submit
end
TTD
  • 301
  • 1
  • 7