Created
October 11, 2012 14:19
-
-
Save bogn/3872667 to your computer and use it in GitHub Desktop.
Tire: STI field _type get's corrupted by update_index callback on second call to save
This file contains hidden or 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
require 'mongo_mapper' | |
MongoMapper.database = 'testing' | |
require 'tire' | |
class Thing | |
include MongoMapper::Document | |
include Tire::Model::Search | |
include Tire::Model::Callbacks | |
end | |
class SubThing < Thing | |
end | |
s = SubThing.create # => #<SubThing _id: BSON::ObjectId('5076d365d92b09213d000001'), _type: "sub_thing"> | |
# _type is actually persisted as SubThing as you can see with a reload | |
s._type # => "sub_thing" | |
SubThing.count # => 1 | |
s.save # => true | |
s._type # => "sub_thing" | |
SubThing.count # => 0 !!! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is referred to by an issue on the tire gem: karmi/retire#477