# Msdd update

**URL:** <https://www.ruby-forum.com/t/msdd-update/171547>\
**Category:** Rails\
**Created:** [July 4, 2009, 11:36pm UTC](https://www.ruby-forum.com/t/msdd-update/171547 "2009-07-04T23:36:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mistressjanna](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/3ab097/32.png) [@mistressjanna](https://www.ruby-forum.com/u/mistressjanna)\
**Post date:** [July 4, 2009, 11:36pm UTC](https://www.ruby-forum.com/t/msdd-update/171547/1 "2009-07-04T23:36:50Z")

</div>

I must be missing something. I have a list of values returned (id’s to  
my ‘associates’ table) and I want to update all of those in the list.  
Presently, I iterate through the list, updating each one (see below).

Isn;t there a way I can do this all in one fell swoopy in RoR, without  
having to iterate through the list? -Janna B.

params[:form\_\_list1].each do |id|  
associate = Associate.find(id)  
associate.update\_attributes({:channel\_id =\>  
@channel.id, :joined\_channel\_datetime =\> DateTime.now})  
end

---

<div class="post-metadata">

**Author:** ![mistressjanna](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/3ab097/32.png) [@mistressjanna](https://www.ruby-forum.com/u/mistressjanna)\
**Post date:** [July 5, 2009, 12:06am UTC](https://www.ruby-forum.com/t/msdd-update/171547/2 "2009-07-05T00:06:38Z")

</div>

On Sat, Jul 4, 2009 at 2:35 PM, JannaB [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> ```
> associate.update_attributes({:channel_id =>
> 
> ```
> 
> @channel.id, :joined\_channel\_datetime =\> DateTime.now})  
> end

option 1: try using update\_all

Note: Please see API documentation for further explaination.

option 2: rework the original code to eliminate the find call within  
the  
block and iterate over the Association instances

associates = Associate.find( params[:form\_\_list1] )  
associates.each do | associate |  
associate.update\_attributes( {:channel\_id =\> @channel.id,  
:joined\_channel\_datetime =\> DateTime.now } )  
end

Good luck,

-Conrad
