On 13 Jan 2008, at 22:35, Jeremy wrote:
>
> Hello...this amounts more to SQL questions rather than Rails specific
> I guess. I''m new to both.
>
> Basically what I''m trying to do is perform a search for sites
which
> are available for a reservations system. I have a Sites model and I
> have a Reservations model. Reservations contains columns for
> checkindate and checkout date. I also created a model for Booking
> status, which has columns for site_id and date to show which dates and
> which sites are booked, but I''m not even sure I necessarily need
this
> table if there''s a way to query just using the Sites and
Reservations
> models.
>
> The parameters I want to use at this point for the query is to let the
> user choose a checkindate and a checkout date and I want to return a
> list of sites which are available.
I''ve done something slightly different, where there was only one site,
but that site could have multiple reservations for any given date (and
with a varying number of available places on any given day).
Effectively, what i did was have an availabilities table, where each
row states that the site in question is available on the given time
segment (in your case, a single day).
You can then say ''give me the sites which have availabilities in the
given date range'' and then check that the sites returned have all of
those availabilities, not just some of them (you may be able to roll
that all into one query.
Fred
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---