rails/rails — pull request #7839 by chancancode (2012-10-04 01:51:49+00:00)
Title: Handle aliased attributes in AR::Relation

I started experimenting with `alias_attribute` in my STI models and got quite frustrated by the second-class support for attributes aliasing. Ideally if you aliased an attribute all the AR methods should be able to resolve the real column name automatically, just like if you have set `self.table_name = ...` then all of AR (associations, etc) will be made aware of that and do the right thing.

This commit added support for aliased attributes in the finders, calculation methods, counting and pluck. This doesn't cover everything, but I believe it's a step in the right direction, and fixed this in places where it matters the most (finders).

@jonleighton and @rafaelfranca can you take a look? (This basically builds on top of #6800)