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 rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
Just a hunch, but for starters index is a reserved mongoid word so for starters try changing your class name. Regards, David -- 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 rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/1yNhSxUTqmgJ. For more options, visit https://groups.google.com/groups/opt_out.
Just a hunch, but for starters index is a reserved mongoid word so for starters try changing your class name. Regards, David -- 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 rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/tHAUshsRiIYJ. For more options, visit https://groups.google.com/groups/opt_out.