That's because your super
call will pass your custom arguments to the Mongoid::Document
initializer that expects (up to) two hashes, not two objects.
The solution is either to call super()
, it will pass no arguments, or to rewrite the constructor to pass only additional arguments:
def initialize(objectA, objectB, args = nil, options = nil)
super(args, options)
@objectA = objectA
@objectB = objectB
end