i’m working with a has_many :through association. a person has many
people through connections.
connection is the join model. the first step for the UI was to only
allow the creation of one connection at a time. I would show a
primary person and a list of possible connections with radio buttons.
the user would choose only one and hit submit. that’s clearly
restful: a POST to the create method in the ConnectionsController.
now, however, i’d like to allow users to create more than one
connection at a time. the app will present a checkbox list of
possible connections and the user can create many connections with one
submit.
Now the RESTful vision gets muddy for me.
I started writing a bulk_create method in my ConnectionsController,
but the controller started to feel less pure.
What should I do?
- add a bulk_create method and have it loop through the array of
people do many POSTs to the original create method?
or - add a bulk_create method and have it work directly to the
Connection model?
or - add a new array parameter to the orig create method so that a POST
would create many new connections at once.
or is there another option? none of these feel like ideal. i’m
guessing this is a pattern that folks have encountered. but I didn’t
have much luck searching around.
-b