Remove Ransack from Exercise edit for tags

* Also improve Ransack usage of attributes and associations
This commit is contained in:
Sebastian Serth
2022-08-20 01:28:47 +02:00
parent 83feb67dd5
commit 166aa3cc6f
10 changed files with 46 additions and 3 deletions

View File

@ -461,8 +461,7 @@ class ExercisesController < ApplicationController
private :set_file_types
def collect_set_and_unset_exercise_tags
@search = policy_scope(Tag).ransack(params[:q])
@tags = @search.result.order(:name)
@tags = policy_scope(Tag)
checked_exercise_tags = @exercise.exercise_tags
checked_tags = checked_exercise_tags.collect(&:tag).to_set
unchecked_tags = Tag.all.to_set.subtract checked_tags