Msdd update

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

On Sat, Jul 4, 2009 at 2:35 PM, JannaB [email protected]
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