I have the following models:
class GrandParent < ActiveRecord::Base
has_many :parents
has_many :children, through: :parents
end
class Parent < ActiveRecord::Base
has_many :children
belongs_to :grand_parent
end
class Child < ActiveRecord::Base
belongs_to :parent
end
I'd like to find all Children where the a child's grand_parent has a value equal to TRUE, but I'm having trouble getting the syntax right. Something like:
Child.where(grand_parent.value: TRUE)