I have two models User and Subscription as follows
class User < ApplicationRecord
has_many :subscriptions
end
class Subscription < ApplicationRecord
belongs_to :user
# attributes
# name string
# premium boolean
# ...
end
Users will be having many subscription. How Can I find all the users who does not have a premium subscription (premium =true)
User.where('id not in (select user_id from subscriptions where premium = true)'). This works for me with subquery. Is there a better way of doing the same with joins?