# Is there a RESTful way to bulk create?

**URL:** <https://www.ruby-forum.com/t/is-there-a-restful-way-to-bulk-create/139145>\
**Category:** Rails\
**Created:** [May 31, 2008, 12:40pm UTC](https://www.ruby-forum.com/t/is-there-a-restful-way-to-bulk-create/139145 "2008-05-31T12:40:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![brian\_mulloy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/73ab20/32.png) [@brian\_mulloy](https://www.ruby-forum.com/u/brian_mulloy)\
**Post date:** [May 31, 2008, 12:40pm UTC](https://www.ruby-forum.com/t/is-there-a-restful-way-to-bulk-create/139145/1 "2008-05-31T12:40:49Z")

</div>

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?

1. add a bulk\_create method and have it loop through the array of  
people do many POSTs to the original create method?  
or
2. add a bulk\_create method and have it work directly to the  
Connection model?  
or
3. 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

---

<div class="post-metadata">

**Author:** ![brian\_mulloy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/73ab20/32.png) [@brian\_mulloy](https://www.ruby-forum.com/u/brian_mulloy)\
**Post date:** [May 31, 2008, 12:47pm UTC](https://www.ruby-forum.com/t/is-there-a-restful-way-to-bulk-create/139145/2 "2008-05-31T12:47:50Z")

</div>

or maybe I do a post to the index?

-b

---

<div class="post-metadata">

**Author:** ![brian\_mulloy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/73ab20/32.png) [@brian\_mulloy](https://www.ruby-forum.com/u/brian_mulloy)\
**Post date:** [May 31, 2008, 12:49pm UTC](https://www.ruby-forum.com/t/is-there-a-restful-way-to-bulk-create/139145/3 "2008-05-31T12:49:36Z")

</div>

err. duh. scratch that.
