Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

There was a problem

You must be a member of this account.

This project is archived and is in readonly mode.

Reloading in the console stops observer callbacks

#6068

Calling reload! in the console stops all observer callbacks from being fired on new instances of records (old records in memory still work).

class GizmoObserver < ActiveRecord::Observer
  def after_save(gizmo)
    puts "after_save(#{gizmo})"
  end
end

And now in a console:

$ rails c
Loading development environment (Rails 3.0.3)
ruby-1.9.2-p0 > (g = Gizmo.first).save
after_save(#<Gizmo:0xa59df94>)
 => true
ruby-1.9.2-p0 > reload!
Reloading...
 => true
ruby-1.9.2-p0 > Gizmo.first.save
 => true
ruby-1.9.2-p0 > g.save
after_save(#<Gizmo:0xab806b4>)
 => true

Reported by Samuel Kadolph · November 25th, 2010 @ 09:06 PM

State: resolved
Milestone: none
Assigned to: José Valim José Valim
Importance: Low

Activity

  1. Neeraj Singh
    Neeraj Singh
    • State changed from new to open
    • Importance changed from to Low

    November 25th, 2010 @ 10:23 PM

  2. Neeraj Singh
    Neeraj Singh
    • Assigned user set to José Valim

    I have a response here https://gist.github.com/742099 .

    Assigning it to JV since he knows much more about this kind of stuff.

    December 15th, 2010 @ 03:58 PM

  3. José Valim
    José Valim

    Great debugging Neeraj.

    Unfortunately, I am not sure on how to fix this problem. We need console to be executed as it would be inside a request... we could do that by passing something like IRB.start as the app, but I did a small proof of concept and got a lot of warnings every time we call IRB.start more than once. So not sure.

    December 15th, 2010 @ 05:13 PM

  4. Ravil Bayramgalin
    Ravil Bayramgalin

    I can not reproduce on master. Seems it was fixed.

    December 25th, 2010 @ 01:30 PM

  5. José Valim
    José Valim
    • State changed from open to resolved

    Yes, I have fixed the issue. Sorry, I forgot to ping back here.

    December 25th, 2010 @ 01:36 PM

  6. Ravil Bayramgalin