Home Get dropdown selected value and fetch data from join table
Reply: 0

Get dropdown selected value and fetch data from join table

user1134 Published in March 23, 2018, 7:03 am

I have two tables:

class Assessment
  has_many :students, through: :assessment_students

class Student
  has_many :assessments, through: :assessment_students

class AssessmentStudent
  belongs_to :student
  belongs_to :assessment

There is another table:

class Classroom
  has_many :classroom_students

When a new assesssment is created, user can choose a classroom to which assessment belongs and all students of that classroom is assigned to the assessment. Join table (AssessmentStudent) and Assessment table get the updated values.

On show.html of Classroom, I have to show all assessments of that classroom as a dropdown. I am able to get this dropdown displaying the assessments. Now based on the assessment chosen in the dropdown, I have to get student details assigned to that particular assessment (This data is available in join table AssessmentStudent). However, I am not sure how to get the selected dropdown value and loop through all records of AssessmentStudent join table and get the relevant student data.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.358315 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO