Topic: Problem with a list
Ok, here's what I'm trying to do. I've got an application that will display a list of apartments. The database is broken down like this:
Area (id, name) has_many :buildings
Building (id, address, area_id) belongs_to :area, has_many :apartments
Apartment (apt_number, building_id) belongs_to :building
I've got a controller called Listing that works with the Apartment model. The Listing index.rhtml file basically just shows a list of the areas by name (ie: North, South, East, West). What I would like is to be able to click on one of the areas and have it display a simple table of just the apartments in that particular area.
What I think I should be able to do is have the link call the list method, which would then sort the data by the area id (apartment.building.area_id). But when I tried using :conditions => "building.area_id = '3', it locked up. Also, I'm not entirely sure how to pass an argument to the list method from the list of areas, or if that is even possible.
Any suggestions on how I can make this work?