This project is archived and is in readonly mode.
missing SomeModel#id after reset_subclasses
-
Kazuhiro Nishiyama
The attached test case scirpt is an individual script, because test environment is with config.cache_classes = true, but the problem occurs with config.cache_classes = false.
-
Pratik
- State changed from new to wontfix
- Assigned user set to Pratik
- Tag set to 2.0-stable, activerecord, bug, edge, patch
Why are you calling reset_subclasses ? Can you not just call ActiveSupport::Dependencies.clear ?
Anyone has thoughts on how to test this ?
Thanks.
-
Kazuhiro Nishiyama
Calling reset_subclasses is a minimal case.
I met this problem with passenger-1.0.5 and rails-2.0.2.
I do not reproduce the problem with passenger-2.0.1 and rails-2.1.0.
Thanks.
-
ogryb
- Tag changed from 2.0-stable, activerecord, bug, edge, patch to 2.0-stable, activerecord, bug, edge, patch
I'm having a bigger problem with 'reset_subclasses' in the following scenario:
- Class A is derived from ActiveRecord
- Class B is derived from A
Class B looks OK when it's created first time. After reset_subclasses is called all methods of class B get deleted, but methods of class A are still there. Next time when class B is used I'm getting exceptions because all methods of class B and 'id' are still missing. It happens only if caching is off (config.cache_classes = false).
I need to fix it somehow. Please let me know what code is responsible for re-creating a class after it was processed by reset_subclasses. Probably I'll fix it there.
It happens in Rails 2.0.2 and 2.1.1 with both ruby 1.8.7 and 1.8.6.
If you know any other "work around" please let me know too.
Below is the piece of code that cripples my classes:
def self.reset_subclasses #:nodoc: ....
klass.instance_methods(false).each { |m| klass.send :undef_method, m } -
ogryb
I've changed undef_method to remove_method, but it didn't help - I'm still getting NoMethodError for the methods that are defined in class B.
Any other ideas?
