ruby on rails - How select users where with paid is true and paid_subscriptions expirence_at current date? -
i have model user
has_many: paid_subscriptions
model paidsubscription
belongs_to :user
how me write active record query select users, paid
true
, paid_subscriptions
expirence_at
< current day?
edit:
user.includes(:paid_subscriptions).where("year(created_at) = ? , active = ?", 2011, true).where('paid_subscriptions.expirence_at < ?', date.today)
you can try following:
user.includes(:paid_subscriptions) .where('year(users.created_at) = ? , users.active = ? , paid_subscriptions.expirence_at < ?', 2011, true, date.today)
Comments
Post a Comment