I m new in rails and I have a problem recording data in database with a has_and_belongs_to_many relationship.
I have a
has_and_belongs_to_many relationship between
class Participant < ActiveRecord::Base has_and_belongs_to_many :events, join_table: :events_participants end
class Event < ActiveRecord::Base has_and_belongs_to_many :participants, join_table: :events_participants end
event form, i have a
collection_check_boxes to select participants:
<%= collection_check_boxes(:event, :participants, Participant.all, :id, :name) %>
And lastly in the
events_controller, I define the require params like this:
The rest of code is the code auto-generated by rails g scaffold command.
So, the question is: when i select one (or more)
Event form through the checkboxes and press the submit button, I can see the
INSERT INTO Event SQL generated, but nothing about
INSERT INTO events_participants
What am I doing wrong?
Thanks in advance,