My application will need to store many measurements (eg: temperature)
for a set of locations (eg: roof) and periodically recall those
measurements for charting, browsing, or editing.
class Location < ActiveRecord::Base
class Measurement < ActiveRecord::Base
I would like the measurements to be kept in the order in which they
are taken and stored in the database so that a potentially expensive
sorting operation is not required every time the user queries a
location’s temperature history.
If I implemented this with a linked list, I would add new temperature
measurements to the head and traverse down the list as needed for a
deterministic retrieval. Will Rails perform a conceptually similar
operation and store/retrieve Measurement instances in a determinsitic
manner? If not, are there any recommendations for preserving order in
a has_many relationship?