This project is archived and is in readonly mode.
Reloading in the console stops observer callbacks
Reported by Samuel Kadolph | November 25th, 2010 @ 09:06 PM
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
Comments and changes to this ticket
-
Neeraj Singh November 25th, 2010 @ 10:23 PM
- State changed from new to open
- Importance changed from to Low
-
Neeraj Singh December 15th, 2010 @ 03:58 PM
- 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.
-
José Valim December 15th, 2010 @ 05:13 PM
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.
-
José Valim December 25th, 2010 @ 01:36 PM
- State changed from open to resolved
Yes, I have fixed the issue. Sorry, I forgot to ping back here.
-
Ravil Bayramgalin December 25th, 2010 @ 02:35 PM
Jose, can you please provide feedback on https://rails.lighthouseapp.com/projects/8994/tickets/6196-patch-im... ?
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>