Stack error/infinite recursion with latest rails


#1

i just ran ‘yes|gem install rails --remote’

and

Company.find :all
SystemStackError: stack level too deep
from
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.1/lib/active_record/callbacks.rb:215:in
instantiate_without_callbacks' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.1/lib/active_record/callbacks.rb:215:ininstantiate’
from
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.1/lib/active_record/base.rb:431:in
find_by_sql' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.1/lib/active_record/base.rb:431:infind_by_sql’
from
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.1/lib/active_record/base.rb:395:in
`find’
from (irb):3

the sources shows this

 module ClassMethods #:nodoc:
   def instantiate_with_callbacks(record)
     object = instantiate_without_callbacks(record)

     if object.respond_to_without_attributes?(:after_find)
       object.send(:callback, :after_find)
     end

     if object.respond_to_without_attributes?(:after_initialize)
       object.send(:callback, :after_initialize)
     end

     object
   end
 end

but we also have


base.extend(ClassMethods)
base.class_eval do
class << self
include Observable
alias_method :instantiate_without_callbacks, :instantiate
alias_method :instantiate, :instantiate_with_callbacks
end

so instantiate_without_callbacks calls :instantiate which calls
:instantiate_with_callbacks which calls instantiate_without_callbacks

this can’t be good. what’s the fix?

-a

===============================================================================
| ara [dot] t [dot] howard [at] noaa [dot] gov
| all happiness comes from the desire for others to be happy. all misery
| comes from the desire for oneself to be happy.
| – bodhicaryavatara