simplified some Active Record queries

This commit is contained in:
Hauke Klement
2015-03-11 14:31:19 +01:00
parent a06e20b6c5
commit a8bda864df
6 changed files with 6 additions and 6 deletions

View File

@ -22,7 +22,7 @@ class ExercisePolicy < AdminOrAuthorPolicy
if @user.admin?
@scope.all
elsif @user.internal_user?
@scope.where("user_id = #{@user.id} OR public = TRUE OR (team_id IS NOT NULL AND team_id IN (SELECT t.id FROM teams t JOIN internal_users_teams iut ON t.id = iut.team_id WHERE iut.internal_user_id = #{@user.id}))")
@scope.where('user_id = ? OR public = TRUE OR (team_id IS NOT NULL AND team_id IN (SELECT t.id FROM teams t JOIN internal_users_teams iut ON t.id = iut.team_id WHERE iut.internal_user_id = ?))', @user.id, @user.id)
else
@scope.none
end