Forum: Ruby on Rails How do I retrieve Errors from multiple updates

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
60e38de043848f82392062088f191213?d=identicon&s=25 HOGANBP (Guest)
on 2005-11-18 17:58
(Received via mailing list)
Hey all,

I'm attempting to do a multiple record update and all is saving well,
but I can't figure out how to display the errors.
Does anyone know how I can get the error messages back to the
flash[:notice] from this code?  The @task variable below seems to
contain an array of some sort..... But I can't figure out what to call
to get the error message.

      @task = Task.update @params['task'].keys, @params['task'].values

I would really appreciate it if someone had some code they could send me
that would show me how to display each error message (if one exists). I
can see the error messages in the below dump but I can't figure out how
to get at them.

@task.size  => 2


#<Task:0x34f5c78 @attributes={"status"=>"0000000000",
"created_on"=>"2005-10-10", "started_on"=>nil, "name"=>"test",
"assigned_to"=>"1", "project_id"=>"9", "completed_on"=>nil,
"esthours"=>"6", "published"=>"0", "creator_id"=>"1", "priority"=>"0",
"service_id"=>"2", "id"=>"74", "description"=>"test", "difficulty"=>"0",
"due_on"=>"2005-11-24"}, @errors=#<ActiveRecord::Errors:0x34f3f38
@base=#<Task:0x34f5c78 ...>, @errors={}>, @new_record_before_save=nil>,

#<Task:0x3491670 @attributes={"status"=>"0000000000",
"created_on"=>"2005-10-10", "started_on"=>nil, "name"=>"Test new
procedures on DBMS04", "assigned_to"=>"1", "project_id"=>"9",
"completed_on"=>nil, "esthours"=>"5", "published"=>"0",
"creator_id"=>"4", "priority"=>"5", "service_id"=>"2", "id"=>"75",
"description"=>"The new stored procs need to be tested",
"difficulty"=>"3", "due_on"=>"2005-10-25"},
@errors=#<ActiveRecord::Errors:0x348dec0 @base=#<Task:0x3491670 ...>,
@errors={}>, @new_record_before_save=nil>

Help is much appreciated!

Brian Hogan
Web Development
Learning & Technology Services
Schofield 3-B
University of Wisconsin-Eau Claire
715 836 3585
This topic is locked and can not be replied to.