On Sun, Oct 25, 2009 at 2:11 PM, Misiek Sz <rails-mailing-l...@andreas-s.net> wrote: > > Leonardo Mateo wrote: >> On Sat, Oct 24, 2009 at 7:09 PM, Misiek Sz >> <rails-mailing-l...@andreas-s.net> wrote: >>> made to the get_student_info method where student info is pulled and >>> �<tr> >>> � �<%= observe_field(:st_id, :frequency => 0.25, :update => >>> � �<td><%= f.label :service_code %></td> >>> >>> EducationPlan controller. >> The error message says that you're calling a method on a nil object. >> If you uncomment that line, you will be calling the student_id method >> on @education_plan instance, but @education_plan is nil there. >> >> -- >> Leonardo Mateo. >> There's no place like ~ > > Thanks. Why is it nil if the method is part of the controller? Which method is part of the controller? you are referencing an instance variable (@education_plan) which is not defined yet. The method in question, here, is student_id which is from the model (EducationPlan) but the object where you're trying to call this method from is not of a EducationPlan instance, it is not even an instance, it is nil, and that's why you get that error.
> > And also how can I create an association between education_plan and > student based on the ajax call from education_plan? > I really don't understand how you want to do the association here. The AJAX call behaves exactly as any other calls in the terms of the controller. If a Student has one EducationPlan, and you have: @student = Student.find(whatever) you should be able to do: @student.education_plan and @student.education_plan= So, if you're retrieving the student from the database, you'll get the associated education plan. It looks like you have a misconception of the ActiveRecord associations, have you read the guide[1] for this? maybe it can help you to get it right. [1]http://guides.rubyonrails.org/association_basics.html Hope it helps.- -- Leonardo Mateo. There's no place like ~ --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---