# Adding "update all" functionality

**URL:** <https://www.ruby-forum.com/t/adding-update-all-functionality/110755>\
**Category:** Rails\
**Created:** [July 30, 2007, 5:28pm UTC](https://www.ruby-forum.com/t/adding-update-all-functionality/110755 "2007-07-30T17:28:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sclaerhout](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/85f322/32.png) [@sclaerhout](https://www.ruby-forum.com/u/sclaerhout)\
**Post date:** [July 30, 2007, 5:28pm UTC](https://www.ruby-forum.com/t/adding-update-all-functionality/110755/1 "2007-07-30T17:28:26Z")

</div>

I have a simple model called â€œfooâ€ and Iâ€™m using the scaffold generated  
code. When I edit â€œfooâ€ I want to be able to click a check box that says  
â€œupdate allâ€. When the param is passed I cycle through all the â€œfoosâ€ in  
the database and update them with the single â€œfooâ€ form variablesâ€¦if the  
param isnâ€™t passed then it only updates the selected â€œfooâ€.

I have a sample that works but it bypasses all the validation. Also, I  
get stale object errors because the lock\_version for the unselected  
models isnâ€™t getting incremented when itâ€™s selected for edit, since itâ€™s  
never selected.

Has anyone done this before?

Thanks,

Scott
