I have the following query
SubCategory.joins(dropdown_heads: :dropdown_lists).where(id: params[:sub_cat_id])
The above query generates
SELECT "sub_categories".* FROM "sub_categories" INNER JOIN "dropdown_heads" ON "dropdown_heads"."sub_category_id" = "sub_categories"."id" INNER JOIN "dropdown_lists" ON "dropdown_lists"."dropdown_head_id" = "dropdown_heads"."id" WHERE "sub_categories"."id" = 6
But what I actually need is to fetch records from dropdown_heads and dropdown_lists only.
What modification do I need to achieve it?
Following are the associations
sub_category.rb
has_many: dropdown_heads
dropdown_head.rb
has_many: dropdown_lists
belongs_to: sub_category
dropdown_lists.rb
belongs_to: dropdown_head