Reputation: 25542
I have the following Scope:
def coming_up_on_renewal(product_name = "product_name")
where('billing_start_date = NOW() + INTERVAL 3 day AND status = ? AND product_name = ? AND auth_net_subscription_id IS NOT NULL', :active, "#{product_name}")
end
And I have manipulated a single record in my database to be 3 days in the future, yet when I run this scope, an empty array is returned.
I am basically trying to retrieve records where the billing_start_date
is 3 days from the current day.
Upvotes: 2
Views: 626
Reputation: 10856
Have a try with this.
def coming_up_on_renewal(product_name)
where(:status => :active, :product_name => product_name)
.where(:billing_start_date =>
(3.days.from_now.beginning_of_day)..(3.days.from_now.end_of_day))
.where('auth_net_subscription_id IS NOT NULL')
end
For your additional "IS NOT NULL" condition see this answer.
Upvotes: 4