对Mongoid::Document子类的访问属于
我有一个模型“索引”,如下所示:对Mongoid::Document子类的访问属于,mongoid,has-many,sti,Mongoid,Has Many,Sti,我有一个模型“索引”,如下所示: class Index include Mongoid::Document belongs_to :project end 另一个模型PercentileRankIndex继承指数 class PercentileRankIndex < Index def self.model_name Index.model_name end end 我明白了: #<PercentileRankInd
class Index
include Mongoid::Document
belongs_to :project
end
另一个模型PercentileRankIndex继承指数
class PercentileRankIndex < Index
def self.model_name
Index.model_name
end
end
我明白了:
#<PercentileRankIndex _id: 51630ece34b2613d27000011, project_id: "51630ece34b2613d27000010", enabled: true, _type: "PercentileRankIndex", :enabled: "true">
#
然而在做
p、 计划
=>零
“属于”关系在子类上不起作用。为什么?我怎样才能修好它
#<PercentileRankIndex _id: 51630ece34b2613d27000011, project_id: "51630ece34b2613d27000010", enabled: true, _type: "PercentileRankIndex", :enabled: "true">