[Rails] saving a collection

Dan Kubb dan.kubb at autopilotmarketing.com
Sun Jan 1 18:44:08 GMT 2006


> On the other hand, you probably also need to make sure the records are
> valid, so..
> good_to_go = true
> @collection.each do |record|
>   good_to_go = false unless record.save
> end
> flash[:notice] = "All records saved. Lunch break!" if good_to_go
> etc, etc, etc.

You could also do it like this:

   good_to_go = @collection.all? { |r| r.save }

-- 

Dan





More information about the Rails mailing list