I have three tables parents, children and fundings.
parent.rb
class Parent < ApplicationRecord
has_many :children, dependent: :destroy
end
child.rb
class Parent < ApplicationRecord
belongs_to :parent
has_many :fundings, dependent: :destroy
end
funding.rb
class Funding < ApplicationRecord
belongs_to :child
end
Joins between children and fundings
create_table "children_fundings", id: false, force: :cascade do |t|
t.integer "child_id", null: false
t.integer "funding_id", null: false
t.index ["child_id", "funding_id"], name:
"index_children_fundings_on_child_id_and_funding_id"
t.index ["funding_id", "child_id"], name:
"index_children_fundings_on_funding_id_and_child_id"
end
join between children and parents
create_table "children_parents", id: false, force: :cascade do |t|
t.integer "parent_id", null: false
t.integer "child_id", null: false
t.index ["child_id", "parent_id"], name:
"index_children_parents_on_child_id_and_parent_id"
t.index ["parent_id", "child_id"], name:
"index_children_parents_on_parent_id_and_child_id"
end
children table has parent_id, fundings table has child_id. How can I create a join between parents children and fundings table. Please help