I am using mongoid in Rails 3 and I came across this problem:
Let's say I have a Shape model:
class Shape
include Mongoid::Document
field :x, type: Integer
field :y, type: Integer
embedded_in :canvas
end
And a Canvas model (has many Shapes):
class Canvas
include Mongoid::Document
field :name, type: String
embeds_many :shapes
end
Then a Canvas model "has many Shapes".
I have Browser model inherited from Canvas:
class Browser < Canvas
field :version, type: Integer
end
Then Browswer model should "has many Shapes" now.
But, now I have a "Circle" model inherited from Shape:
class Circle < Shape
field :radius, type: Float
end
And I want to let Browser model to "has many Circles" instead of "has many Shapes". That is to say, I want to overwrite the "has many" relationship in Browser model from "has many Shapes" to "has many Circles".
How should I do it?