Created
June 15, 2012 12:14
-
-
Save arsduo/2936175 to your computer and use it in GitHub Desktop.
???
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
1.9.2p290 :007 > Mongoid::Document.send(:include, ActiveModel::SerializerSupport) | |
=> Mongoid::Document | |
1.9.2p290 :008 > Mongoid::Document.include?(ActiveModel::SerializerSupport) | |
=> false | |
1.9.2p290 :009 > Mongoid::Document.included_modules | |
=> [ProprietaryModule] | |
1.9.2p290 :014 > Mongoid::Document.ancestors | |
=> [Mongoid::Document, ProprietaryModule] |
Mongoid::Document doesn't appear to define its own include method, though I haven't dug through all the modules it includes.
Cannot reproduce in isolation:
fxn@cauchy:~/tmp $ cat foo.rb
require 'rubygems'
require 'mongoid'
module M
end
Mongoid::Document.send(:include, M)
p Mongoid::Document.ancestors
fxn@cauchy:~/tmp $ ruby foo.rb 2>/dev/null
[Mongoid::Document, M]
OK Alex, I didn't read your full comment, sorry :D
Could it be a 1.9.2-specific issue? What ruby version are you using, @fxn?
I'm on ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.3.0]. I can't rule out that it has something to do with all the other gems (including Rails) that I'm loading...but on the plus side, I've figured out how to do what I need to do in Mongoid 3 without having to switch serializers, so while I'd like to do that and figure this out, it's a lot less urgent.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Mongoid is being loaded by a gem that's including the ProprietaryModule in it; this code (executed here in a rails console) should be executed inside an initializer (per http://autonomousmachine.com/posts/2012/5/5/use-active-model-serializers-with-mongoid).