-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
-
None
As per the classic example for how to get an InvalidSetPolymorphicRelation:
class Face
include Mongoid::Document
has_one :left_eye, class_name: "Eye", as: :eyeable
has_one :right_eye, class_name: "Eye", as: :eyeable
end
class LeftEye
include Mongoid::Document
belongs_to :eyeable, polymorphic: true, inverse_of: :left_eye
end
class RightEye
include Mongoid::Document
belongs_to :eyeable, polymorphic: true, inverse_of: :right_eye
end
eye = LeftEye.new
face = Face.new
eye.eyeable = face # Raises Mongoid::Errors::InvalidSetPolymorphicRelation
If we add an extra class and specify which relationship we're referring to (inverse_of), it still blows up. Should this not be valid?