On Apr 17, 8:10 pm, Frederick Cheung <[email protected]>
wrote:
>
> It's trying to minimise the number of delete or updates to the
> database, so it first removes all the records that should no longer be
> there, then appends all the records that need to be added to the
> collection, which will mess with your order if the collection is non
> empty to begin with
>
> If you reload the association the records should come out in the right
> order
self.shifts = (newshifts.to_a + currentshifts.to_a).sort_by { |a|
a.date }
# Reload to get them in order
self.shifts.reload
That seems to work (or at least passes my test cases ;) ), thanks a
lot!
Sean
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---