I''ve written a daemon that uses ActiveRecord. I''m new to
Ruby, so I
like to set $VERBOSE to true. When my daemon runs, I get warnings
from four different places within ActiveRecord. All four are
instances of accessing an instance variable that hasn''t yet been
brought into existence. In each case there''s a test for nil, so
nothing unsafe is being done.
I can make three of the warnings go away by merely adding a defined?
to an existing test. I didn''t find a nice way to get rid of the
remaining warnings. Having ActiveRecord::Base supply a non-warning
version of instance_variable_get works, but I don''t like that
solution.
I''ve attached a patch for ActiveRecord 1.12.2 that makes the warnings
go away, to illustrate what I''m talking about. I''m not
lobbying for
the patch to be included, because I have no idea how many other places
ActiveRecord will throw warnings. I also don''t have a good feel for
Ruby / RoR performance. I''d guess that the three simple defined?
tests wouldn''t consume any measurable time, but the
instance_variable_get implementation which uses instance_eval might
slow things down enough to be noticeable (I also did a version that
saves and restores $VERBOSE, but $VERBOSE isn''t thread-local, so that
seems like a bad idea).
Are most people doing RoR work with $VERBOSE set to false? Am I
foolish to be doing RoR development with it set to true?
--
Cliff Matthews <ctm-8zsHZIedDRE@public.gmane.org>
_______________________________________________
Rails mailing list
Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails