Is it possible in Rails, to create an "empty" ActiveRecord Query object for a given model? Empty means for me a condition, that includes all possible rows in the db. I want to apply filters to that query afterwards.
At the moment I am using Booking.where('id > ?', 0), but I believe there has to be a nicer way like Booking.all() - but all() returns an array and not an ActiveRecord. Here´s my code:
@bookings = Booking.where('id > ?', 0)
if [email protected]?
@bookings = @bookings.where('day = ?',@day)
end
if @project_id && !@project_id.empty?
@bookings = @bookings.where('project_id = ?', @project_id)
end
Thanks for your help!