Downgraded from Rails 4.1.4 to 4.0.8 due to a HABTM query bug that does not form inner joins