rath
August 31, 2006, 2:57am
#1
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
rath
August 31, 2006, 7:58am
#2
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
rath
August 31, 2006, 6:35am
#3
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.