Answer the question
In order to leave comments, you need to log in
Mongoid for some reason does not pick up the reverse many-to-many self-association of the model?
The model looks like this in a nutshell:
class Task
include Mongoid::Document
has_and_belongs_to_many :dependent_tasks, class_name: "Task", inverse_of: :depending_tasks
has_and_belongs_to_many :depending_tasks, class_name: "Task", inverse_of: :dependent_tasks
attr_accessible :dependent_tasks, :depending_tasks
end
task.depending_tasks << task2 #=> [#<Task _id: 52fa6127e826a69ea2000002, parent_id: nil, dependent_task_ids: ["52fa6123e826a69ea2000001"], depending_task_ids: nil>]
task2 #=> #<Task _id: 52fa6127e826a69ea2000002, parent_id: nil, dependent_task_ids: ["52fa6123e826a69ea2000001"], depending_task_ids: nil>
task2.dependent_tasks #=> []
task2.dependent_task_ids #=> ["52fa6123e826a69ea2000001"]
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question