I have the following situation. I have two table Student and Course linked via HABTM association.
On Student form, I want to have a list of Courses, however I need more information displayed than a simple checkbox and a label next to it. Essentially, I want to have an HTML table with information from my Course model with a checkbox for the association in the first column of the table.
How can this be accomplished?
Essentially this did it:
I iterated through my @courses collection and created each checkbox manually like this:
check_box_tag "student[course_ids][]", course.id
In my controller params I added this:
params.require[:student].permit(... ,course_ids: [])
My Student model needed this:
accepts_nested_attributes_for :courses
Pretty simple if you know what you're doing :-)