# Multiple rows problem

**URL:** <https://www.ruby-forum.com/t/multiple-rows-problem/67036>\
**Category:** Rails\
**Created:** [August 31, 2006, 2:57am UTC](https://www.ruby-forum.com/t/multiple-rows-problem/67036 "2006-08-31T02:57:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rath](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c2a13f/32.png) [@rath](https://www.ruby-forum.com/u/rath)\
**Post date:** [August 31, 2006, 2:57am UTC](https://www.ruby-forum.com/t/multiple-rows-problem/67036/1 "2006-08-31T02:57:24Z")

</div>

## edit.rhtml

\<% for @patient in @patients %\>  
\<%= text\_field “patient[]”, “name” %\>  
\<% end %\>

## doctor\_controller.rb

def update  
@doctor = Doctor.find(params[:id])  
@params[:patient].each do |id, details|  
@patient = @doctor.patients.find(id)  
@patient.update\_attributes(details)  
end  
redirect\_to …  
end

## Error -\> crashing at update\_attributes

Doctor expected, got String

---

<div class="post-metadata">

**Author:** ![rath](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c2a13f/32.png) [@rath](https://www.ruby-forum.com/u/rath)\
**Post date:** [August 31, 2006, 7:58am UTC](https://www.ruby-forum.com/t/multiple-rows-problem/67036/2 "2006-08-31T07:58:06Z")

</div>

Thanks Alex, I fixed the problem.

The problem is that I was using a column name in the patient table  
called doctor and also included doctor\_id… any of these will try to  
get a doctor, therefore the Doctor expected 🙂

Thanks anyway

---

<div class="post-metadata">

**Author:** ![rath](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c2a13f/32.png) [@rath](https://www.ruby-forum.com/u/rath)\
**Post date:** [August 31, 2006, 6:35am UTC](https://www.ruby-forum.com/t/multiple-rows-problem/67036/3 "2006-08-31T06:35:58Z")

</div>

Rath — wrote:

> ## edit.rhtml
> 
> \<% for @patient in @patients %\>  
> \<%= text\_field “patient[]”, “name” %\>  
> \<% end %\>
> 
> ## doctor\_controller.rb
> 
> def update  
> @doctor = Doctor.find(params[:id])  
> @params[:patient].each do |id, details|  
> @patient = @doctor.patients.find(id)  
> @patient.update\_attributes(details)  
> end  
> redirect\_to …  
> end
> 
> ## Error -\> crashing at update\_attributes
> 
> Doctor expected, got String

What does params.inspect yeild when you submit the form for this page?  
That might help you figure out whats going on.
