Everything is working fine the way it is coded but I am fairly new to RoR and want to learn proper practices.
One of the things I do with pundit is to filter the data by a particular School District, so in the "scope" of Pundit I look to see what role the user has and filter the data presented by the districts they are allowed to see.
I'll look at moving some of that to the models instead.
class Scope < Scope
def resolve
if @user.is_global_admin?
scope.all
elsif @user.is_facilitator?
scope.by_districts(@user.district_ids)
elsif @user.is_district_admin(@session[:global_district_id])
scope.by_districts(@user.district_ids)
elsif @user.is_district_user(@session[:global_district_id])
scope.by_districts(@user.district_ids)
elsif @user.is_district_viewer(@session[:global_building_id])
scope.by_districts(@user.district_ids)
elsif @user.is_building_admin(@session[:global_building_id])
scope.by_buildings(@user.building_ids)
elsif @user.is_building_user(@session[:global_building_id])
scope.by_buildings(@user.building_ids)
elsif @user.is_building_viewer(@session[:global_building_id])
scope.by_buildings(@user.building_ids)
elsif @user.is_classroom_user
scope.where(id: @session[:global_building_id])
elsif @user.is_classroom_viewer
scope.where(id: @session[:global_building_id])
else
scope.none
end
end
end