Jeremy wrote:
Can somebody help me out?
I’d think that you’d want a generic Room model, and have the type and
dimensions be attributes of the room. After all, there is a huge variety
in the numbers and types of rooms in any particular dwelling.
Something like:
Room
listing_id (a room belongs to a listing, no?)
room_type
room_dimensions
room_notes (space for stuff like “New Hardwood Floors!” or “New
Tile!”)
- whatever else you decide is important for a room
The room type could be served from another model/table. I typically use
a model called Reflist to store all my ‘reference’ lists that looks like
this (with a Reflists model and views, you can easily add to your
reference lists, leaving it data driven):
Table name: reflists
id :integer(11) not null, primary key
ref_type :string(20) default(""), not null
ref_subtype :string(20)
ref_order :integer(11)
ref_name :string(20) default(""), not null
ref_desc :string(45)
created_at :datetime
created_by :string(10)
updated_at :datetime
updated_by :string(10)
lock_version :integer(11) default(0)
The ref_type lets me distinguish the type of items
ref_subtype is there when I need two levels of categorization
ref_order defines the order of the items
ref_name is the value I want to store in the referring table (like
rooms)
ref_desc is what shows in the droplist control
room_type in the rooms table would hold some value from the reflist
records whose type is ‘Room’
In your case, I might define records like:
ref_type ref_order ref_name ref_desc
‘Room’ 1 ‘Living’ ‘Living Room’
‘Room’ 2 ‘Bedrooom’ ‘Bedroom’
‘Room’ 3 ‘Dining’ ‘Dining Room’
‘Room’ 4 ‘Bath’ ‘Full Bath’
‘Room’ 5 ‘HBath’ ‘Half Bath’
etc, etc
Droplists in views can be populated with a collection_select to choose
the type for each room, like:
collection_select(‘room’, ‘room_type’,
Reflist.find(:all,
:conditions => [“ref_type = ‘Room’”],
:order => ‘ref_order’), :ref_name, :ref_desc,
{ :include_blank => true} )
Of course, this is just one approach.
Soo many possibilities, so little time…