Forum: Ruby on Rails stack error/infinite recursion with latest rails

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
ara.t.howard (Guest)
on 2005-12-09 20:22
(Received via mailing list)
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:in
`instantiate'
         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:in
`find_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
===============================================================================
This topic is locked and can not be replied to.