An array of IDs are being collected
@valid_ts = []
@valid_ts = @valid_ts << dst_1.id
@valid_ts = @valid_ts << dst_2.id
note : each row shown above is in fact run for each member of a collection (i.e. dst_1.size > 1)
When comes time to query the database
slots = Timeslot.where('id IN (?)', @valid_ts).all
the goal is to generate the collection in the order that these members were added to the collection. Rails defaults to updated_at
, otherwise the query has to invoke one of the class's attributes, none of which are useful for the targetted context.
How can the originating order of the array be respected with Rails?