I have a model 'Index' as:
class Index
include Mongoid::Document
belongs_to :project
end
Another model PercentileRankIndex inherits Index
class PercentileRankIndex < Index
def self.model_name
Index.model_name
end
end
Suppose I do :
p = Index.first (OR EVEN) p = PercentileRankIndex.first
I get this :
#<PercentileRankIndex _id: 51630ece34b2613d27000011, project_id:
"51630ece34b2613d27000010", enabled: true, _type: "PercentileRankIndex",
:enabled: "true">
However on doing
p.project
=>nil
The belongs_to relationship isnt working on child class. Why? How can I fix
it?
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msg/rubyonrails-talk/-/vAcQ-Wf4nioJ.
For more options, visit https://groups.google.com/groups/opt_out.