## 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 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
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 StringWhat does params.inspect yeild when you submit the form for this page? That might help you figure out whats going on. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
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 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---