Ruby: Preventing Object#id Warnings
Object#id deprecation warnings can be annoying, especially when they show up in the output from running tests. Sometimes it's hard to track down which test is causing the warning. Fixing this problem is easy:
Place the undef_method line in environment.rb (for Rails apps) or with your other extensions. Although, placing it with other extensions kind of makes extensions a misnomer, since you're actually taking something away...
Object.id #=> 1040020 warning: Object#id will be deprecated; use Object#object_id Object.send :undef_method, :id Object.id #=> NoMethodError: undefined method `id' for Object:Class Object.new.id #=> NoMethodError: undefined method `id' for #<Object:0x356d44>
Place the undef_method line in environment.rb (for Rails apps) or with your other extensions. Although, placing it with other extensions kind of makes extensions a misnomer, since you're actually taking something away...
Posted on 2007-07-24 | permalink | del.icio.us
Blog Archive
