Hello,
So far I've been making selects in the form that end being automatically
mapped to the relationship one-to-many on the database.
Now I am trying to make a multi-select that maps to a many-to-many
relationship. Is that possible ?
I have Courses and Books, many to many. So, when editing a book I output:
It prints correctly, but when saving I get "Course expected, got String". I've
tried with 'course_ids' instead of 'courses' but then I get "undefined method
`course_ids' for #<Book:0xb6eabf94>" when generating the form.
Hello,
So far I've been making selects in the form that end being automatically mapped to the relationship one-to-many on the database.
Now I am trying to make a multi-select that maps to a many-to-many relationship. Is that possible ?
I have Courses and Books, many to many. So, when editing a book I output:
It prints correctly, but when saving I get "Course expected, got String". I've tried with 'course_ids' instead of 'courses' but then I get "undefined method `course_ids' for #<Book:0xb6eabf94>" when generating the form.
How should I do it ?
Yes, association collections should be defining a getter as well as a setter
for the _ids method. You can add one manually: