I get the following error when I use the scope: 

PG::Error: ERROR: column users.order does not exist LINE 1: ...ourse_id" = $1 AND "users"."role" = 'student' AND "users"."o... ^ : SELECT "users".* FROM "users" INNER JOIN "course_memberships" ON "users"."id" = "course_memberships"."user_id" WHERE "course_memberships"."course_id" = $1 AND "users"."role" = 'student' AND "users"."order" = 'last_name ASC'