Skip to content

Instantly share code, notes, and snippets.

@bogn
Created October 11, 2012 14:19
Show Gist options
  • Save bogn/3872667 to your computer and use it in GitHub Desktop.
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
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 !!!
@bogn
Copy link
Author

bogn commented Oct 11, 2012

This is referred to by an issue on the tire gem: karmi/retire#477

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment