Created
July 9, 2013 17:02
-
-
Save abevoelker/5959130 to your computer and use it in GitHub Desktop.
In a Rails controller (in development mode), I somehow got an object that had an invalid or orphaned reference to its class. I'm guessing the class was reloaded at some point by Rails and the Foo constant was changed, but it's weird because I never changed app/models/foo.rb. After I restarted the Rails server the problem was gone. Rails 3.2.13
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@foo # => #<Foo @id=1> | |
Foo.get(1) # => #<Foo @id=1> | |
Foo.get(1) == @foo # => false | |
@foo.as_json == Foo.get(1).as_json # => true | |
Foo.get(1) === @foo # => false | |
@foo.class # => Foo | |
Foo.get(1).class # => Foo | |
@foo.class == Foo.get(1).class # => false | |
@foo.class == Foo # => false | |
@foo.class.object_id # => 25485 | |
Foo.class.object_id # => 144357 | |
Foo.get(1).class.object_id # => 144357 | |
@foo.class.to_s.constantize == Foo # => true | |
@foo.class.to_s.constantize.object_id # => 144357 | |
@foo.class == @foo.class.to_s.constantize # => false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment