Hi all- I''m using single-table inheritance for a table and have created a bunch of tests that deal with the type column of the table. For every single test Rake yells at me with: /opt/local/lib/ruby/gems/1.8/gems/activerecord- 1.10.1/lib/ active_record/validations.rb:247: warning: Object#type is deprecated; use Object#class While this would make sense and be helpful advice if I were trying to get the type of my record, it''s distracting and meaningless when I''m getting at the value of the "type" column. Is there some way I can disable this warning (and the related one for Object#id) in Rake and WEBrick? Thanks, -Dane Jensen
> I''m using single-table inheritance for a table and have created a > bunch of tests that deal with the type column of the table. For every > single test Rake yells at me with: > > /opt/local/lib/ruby/gems/1.8/gems/activerecord- 1.10.1/lib/ > active_record/validations.rb:247: warning: Object#type is deprecated; > use Object#class > > While this would make sense and be helpful advice if I were trying to > get the type of my record, it''s distracting and meaningless when I''m > getting at the value of the "type" column. > > Is there some way I can disable this warning (and the related one for > Object#id) in Rake and WEBrick?Try accessing the type attribute with @model[:type]. As for the Object#id warning, I''ve seen code that throws exceptions on nil.id (since that message crops up when the model you''re trying to access is nil usually), but I can''t remember the exact syntax. -- rick http://techno-weenie.net
On Monday 23 May 2005 13:09, Rick Olson wrote:> As for the Object#id warning, I''ve seen code that throws exceptions on > nil.id (since that message crops up when the model you''re trying to > access is nil usually), but I can''t remember the exact syntax.def nil.id() raise "You took the id of nil -- a model you expect to exist is absent" end or class NilClass undef id end -- Nicholas Seckar aka. Ulysses