All,
I've been struggling to find a neat solution to this problem for a couple
of weeks now, so I'd love to hear anyone else's opinion. I'm on Rails
3.2.13 and Ruby 1.9.3-p392.
I have a table of train schedules, and a table of train schedule locations
with a has_many association. Each schedule has a set of validity dates,
e.g. each Friday between 1st January and 28th September. The times in the
schedule locations table are all 'seconds since midnight on the day the
train runs': where a train runs over midnight, the number of seconds is
greater than 86400.
Whilst this is reasonably 'clean', I want to re-engineer the schedule
location model to return a Time object for each location, calculated on the
fly based on the date I queried the schedule model for, i.e.
Schedule.where(:runs_on => Date.parse('2013-01-01')) will return a Schedule
model with an instance variable 'runs_on', and when I request the
associated schedule locations, the 'arrival_time' and 'departure_time'
fields are auto-calculated based on the instance variable in the schedule
model.
Is this a sensible way to do things? Is this even possible or am I
over-engineering it?
Peter
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msg/rubyonrails-talk/-/BvPG01a8nX4J.
For more options, visit https://groups.google.com/groups/opt_out.