Hi, I'm having trouble with one of my apps.
I'm trying to make a studio booking software.
Before creating a booking, I want to check if the studio is available.
I have a method checking for the availability of the studio which
returns false if the studio is already booked.
The problem is that the method returns 'nil' if the checking process
I tried a bunch of methods but none of them worked
here is my code :
def check_dispo(date, time, time_duration, week_duration)
i = 0
end_time = time + time_duration.strftime('%H').to_i*3600 +
while i < week_duration
studio_bookings = StudioBooking.find(:all, :conditions =>
["start_date = ?", date])
for studio_booking in studio_bookings
studio_booking_end_time = studio_booking.time +
unless time >= studio_booking_end_time || end_time <=
i += 1
date = date + 7