I've been looking around the internet and I don't see an obvious good way to
do what I'd like to do, so I thought I'd ask the group...

I have an object, lets call it Room, that has many dates of availability.
And conversely, on any given day of the year, there may be many Rooms
available.

I'm trying to decide the best way to model this with ActiveRecord.  From a
db perspective, it seems like it would be easy to just have a table called
rooms_days (or something like that) that has two columns.  room_id:int and
day:date.

But because of my lack of experience, I'm not quite sure whether this is
sufficient and how to model it in my ActiveRecord classes.  I started to
imagine saying the Room has_and_belong_to_many :days.  but then I don't have
a model called Day, and I don't really want to make a table that has only
one date column in it because that would add an additional join that seems
unnecessary.

I think maybe there's some way to make a Day model, but not have a table
underneath it, but still tell it to update the RoomDates table via the
association.  Does anyone have experience trying something like this?

Your help is greatly appreciated.
Thanks,
--Jon

--~--~---------~--~----~------------~-------~--~----~
SD Ruby mailing list
[email protected]
http://groups.google.com/group/sdruby
-~----------~----~----~----~------~----~------~--~---

Reply via email to