rails/rails — Issue #3545: Delegate id raise RuntimeError exception when allow_nil is true
Author: ka8725
Created: 2011-11-07 08:04:59+00:00
State: open

Here is explanation how to reproduce problem
>> class A
>> delegate :id, :to => :b, :allow_nil => true
>> attr_accessor :b
>> end
=> nil
>> A.new.id
RuntimeError: Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id
from (irb):12:in `__send__'
from (irb):12:in `id'
from (irb):14

The problem in NilClass that defines id method and raises RuntimeException.