New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ActiveRecord::Base.instantiate_observers does not get called #52
Comments
I don't have any idea. |
Hi, on another box I installed rails 5.0.0.1 from scratch, created an application with minimal features, I added rails-observers from git to the Gemfile and I added a line to application.rb:
I launched rails console and I expected an error to raised however it didn't. In facts the observers are not being loaded. Not in development, neither in production due to reloader.to_prepare's block not being called. Are you able to reproduce this behaviour? |
As a workaround I explicitly added a to_prepare hook that calls ActiveRecord::Base.instantiate_observers. This seemed to work, however Observable.inherited started taking increasing CPU time at each invocation. My application has a hundred classes, and the time taken for each invocation grew up to 5 seconds each, making the application loading in production extremely slow (2 minutes). |
The observers should have been removed a long time ago and with rails 5 there is rails/rails-observers#52 to consider as well.
It looks like this may be related to #45 On Rails 5 stable, the syntax listed in the README (i.e., |
I've only skimmed this issue, but it sounds related to the fix in #65. Try the new 0.1.5! |
Hello,
I'm using Rails 5.0.0.1 with latest master rails-observer.
For some reason I couldn't identify, observers listed in config.active_record.observers suddenly stopped being loaded. I traced the issue in reloader.to_prepare's block not being called and thus ActiveRecord::Base.instantiate_observers not being invoked.
Do you have any idea what could be happening?
The text was updated successfully, but these errors were encountered: