I have a rails app with a data model called ‘jobs’ and I’m faced with a critical design choice crossroads.
I don’t know enough about Rails and its inner workings to be able to say for sure what I should do despite a complete read of the rails and ruby docs.
I want to be able to accurately display the age of a job record in days. So when a customer logs in, they can see that the job they submitted is ‘x’ days old.
Where does a rails app on Heroku get its time stamps? From Heroku? Or the customers system clock?
If a customer has a out of date system clock and submits a job, it could really mess up the sorting of their job list, not to mention me the overseer of job records.
Any advice out there?
EDIT: Just to be clear, i’m not asking how to list jobs by their date, but to which clock does a rails app on Heroku base it’s records.
2
The touch method updates the updated_at
field and save the record. Looking at it’s source code we can see it takes the timestamp from current_time_from_proper_timezone
. Looking at it’s source code we can see it uses a Time.now to fetch the time. Time.now
is an alias to Time.new, which creates a Time
object that according to the documentation “is initialized to the current system time if no argument is given”.
Since all that runs on the server, it uses the local time of the server. So as long as you don’t use JavaScript on the clients machines to calculate the durations, they should be accurate.