Bob wrote:> I''ve got group of updates that I call in certain cases. They
update
> data in different tables if specific conditions are met when a new row
> is saved to the "drive" (see below) database table. I suspect
that I
> should make a method out of the group and reuse it in all the cases,
> but when I do that I''m getting errors that one of the objects is
null.
> Here''s what the method should look like, but it''s not
functioning when
> called.
>
> def goal_achieved_update
> goal.update_attributes (:achieved => 1,
> :achieved_on => @drive.drive_date)
> @best_drive.update_attributes (:state => 1)
> @drive.update_attributes (:state => 8)
> end
>
> Should I be passing arguments to this method? Or perhaps it should be
> in the model and not in the controller?
>
> Any direction to sample code where a update method is created are
> reused would be greatly appreciated.
>
> Thanks for any help!!
> Bob.
Bob,
My guess is that goal is the null object; it is a local variable as
written (without a preceding glyph), but is not initialized within this
context. Perhaps you mean @goal if it is an instance variable?
David B. Williams
http://www.cybersprocket.com
--
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?hl=en
-~----------~----~----~----~------~----~------~--~---