I need to write a query in Rails that involves 3 different models. I need to know which Subscriptions are delivereable. But delivereable is not a column in Subscription but in BasePlan.
class BasePlan
has_many :plans
end
class Plan
has_many :subscriptions
end
class Subscription
belongs_to :plan
end
I've tried joining all three models together to no success:
Subscription.joins(:plans).joins(:base_plans).where(queried_column: true)
What would be the right way to write the query?