I doing an app to allow people to search bus time tables by bus stop and time. My models are: Providers -> Services -> Runs -> Stops <- Stations Key: "->" denotes a one to many Providers = Bus companies Services = the bus number Runs = Columns on a bus time table Stops = Cells on a bus time table, basically a time Stations = Rows on a bus time table StationA 10:00 10:50 11:30 StationB 10:05 10:55 11:34 StationC 10:15 11:10 11:44 StationD 10:17 11:12 11:52 StationE 10:22 11:19 12:00 My question is to do with the model setup and how to search it since the query is quite complex. Model/Tables: I was considering dropping the Stations table and making Stops acts_as_taggable. I assuming tags are simply labels which are shared across models? Also can you add additional information to a tag ie. extra fields? Query: At the moment Im trying to get my head round exactly how to tackle this! Do I have multiple find's or one big ruby style find. Basically the user is going to specify a start and end station and a start and end time. So first of all I need to find all runs that have stops that link to the start and end stations. The end station must be after the start station. Then I need to check to see if the times of those stops fall an hour either side of the times specified by the user. Does this sound right? Is there an easier way to approach this problem? Many thanks, Kris.
on 2006-03-22 14:07