خرید بک لینک

Vote count: 0

What im trying to do, is allow people to input a date range, and find all 'Rental' places that have open days between the provided date range from the user.

My Rentals have a has_many association with "bookings" which contain a start and end date.

What would be the best possible way to get every rental article that has a day that is open within that range.

Im still thinking this problem through, so i have not started coding. But what i was going to do, is find all the Rentals that DONT have bookings that overlap, store those in a variable(because these are correct results, because it means not a single day overlaps).

Then i will find all the Rentals that have bookings that DO overlap. I will then loop through those bookings, and within that, loop through the Range of Dates provided by the user(DateRange.Each) and check if each single day is within that bookings date ranges, as soon as a single day results in a false value(meaning it doesnt overlap) it will end the loop and add the associated "rental" article to the articles collected early with no overlaps at all.

asked 32 secs ago

برچسب: find all rental homes in the 30087,find all rental homes in the 30039, نویسنده: استخدام کار تاريخ: سه شنبه 16 شهريور 1395 ساعت: 18:51

صفحه بندی