Review: multiple named_scopes with duplicate :joins fixed

Hey guys,

We've been chaining lots of named-scopes for advanced searching, and
we're getting killed by the table aliasing issues. Often, multiple
named scopes have to join in the same model (User needs Profile a lot,
for example). When you combine them... aliasing issues!

Can we get some help reviewing this patch, it's our first submission
to core:


-David Stevenson & Joseph Palermo