This is a simple example for this question on stackoverflow:
This application was written for Rails 3.2.21 and would be written slightly differently for Rails 4, particularly with regards to strong parameters and such.
There are two main sets of data: testers and cuisines. When editing a tester the user may choose a set of cuisines for that tester. When editing a cuisine the user may choose a set of testers. The ratings table is the connector between the two.
I didn’t make any tests for this app, so the files in the “test” directory were automatically generated and of no value.
Stick this in a directory and run these commands:
bundle install rake db:migrate rake db:seed rails s
At that point you should have the development server running on:
Connect up and you can modify either testers or cuisines.
In “cuisines”, you can see a standard multi-select list box for testers. In “testers”, you can see a set of check boxes for cuisines. Note that in Rails 4 there is a “collection_check_boxes” method for the form builder which would take the place of the 8 or so lines of code that draw the check boxes.
This code is released into the Public Domain and I renounce the copyright on the parts written by me (Michael Chaney - mdchaney@michaelchaney.com). Use it as you like.