rails/rails — pull request #16051 by matthewd (2014-07-04 15:11:14+00:00)
Title: Provide `prepend_order` and `append_order` relation methods

The multiple-ordering behaviour that was briefly present in 4.0.0 (before it was reverted in 92c5a2244ec3e58fd5e70e7dd2d7882b80183c80) is far more likely to be what people intend: regardless of what it looked like before, immediately after you call `order(:foo)`, the relation will be ordered primarily by `foo`.

But we can't just flip it, because that would create a hidden danger for anyone upgrading. Instead, we'll ask people to be explicit about which behaviour they want, when ordering an already-ordered relation.

I wouldn't be at all surprised if this lead people to existing bugs in their code, where they were subtly assuming `prepend_order` behaviour / unaware that under some conditions their relation was already carrying an order that trumped the one they intended to apply.

Anyway, calling `order` on an already-ordered relation is now deprecated, so we can eventually make `order` an alias for `prepend_order`.

/cc @rafaelfranca