fix user#courses_with_primary_enrollment for rails 3

also fix with_each_shard

Change-Id: Ideb8371e3e36059aeca8ca1b756ca9e9188f1116
Reviewed-on: https://gerrit.instructure.com/29978
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Product-Review: James Williams  <jamesw@instructure.com>
QA-Review: James Williams  <jamesw@instructure.com>