use arel rather than slapping together SQL strings
reorder bind parameters when merging relations
removing useless assingment
save another array allocation
Lock mysql2 version to 0.3.11 since 0.3.12 is failing right now. Check #11457 for details