Upgrade Ransack #search to #ransack to prevent deprecation warning

This commit is contained in:
Sebastian Serth
2019-03-11 09:59:38 +01:00
parent 114f77e799
commit a0b544fb26
6 changed files with 15 additions and 15 deletions

View File

@ -266,7 +266,7 @@ class ExercisesController < ApplicationController
end
def index
@search = policy_scope(Exercise).search(params[:q])
@search = policy_scope(Exercise).ransack(params[:q])
@exercises = @search.result.includes(:execution_environment, :user).order(:title).paginate(page: params[:page])
authorize!
end
@ -319,7 +319,7 @@ class ExercisesController < ApplicationController
private :set_file_types
def collect_set_and_unset_exercise_tags
@search = policy_scope(Tag).search(params[:q])
@search = policy_scope(Tag).ransack(params[:q])
@tags = @search.result.order(:name)
checked_exercise_tags = @exercise.exercise_tags
checked_tags = checked_exercise_tags.collect{|e| e.tag}.to_set

View File

@ -60,7 +60,7 @@ class InternalUsersController < ApplicationController
end
def index
@search = InternalUser.search(params[:q])
@search = InternalUser.ransack(params[:q])
@users = @search.result.includes(:consumer).order(:name).paginate(page: params[:page])
authorize!
end

View File

@ -33,7 +33,7 @@ class ProxyExercisesController < ApplicationController
end
def edit
@search = policy_scope(Exercise).search(params[:q])
@search = policy_scope(Exercise).ransack(params[:q])
@exercises = @search.result.order(:title)
authorize!
end
@ -44,14 +44,14 @@ class ProxyExercisesController < ApplicationController
private :proxy_exercise_params
def index
@search = policy_scope(ProxyExercise).search(params[:q])
@search = policy_scope(ProxyExercise).ransack(params[:q])
@proxy_exercises = @search.result.order(:title).paginate(page: params[:page])
authorize!
end
def new
@proxy_exercise = ProxyExercise.new
@search = policy_scope(Exercise).search(params[:q])
@search = policy_scope(Exercise).ransack(params[:q])
@exercises = @search.result.order(:title)
authorize!
end
@ -63,8 +63,8 @@ class ProxyExercisesController < ApplicationController
private :set_exercise_and_authorize
def show
@search = @proxy_exercise.exercises.search
@exercises = @proxy_exercise.exercises.search.result.order(:title) #@search.result.order(:title)
@search = @proxy_exercise.exercises.ransack
@exercises = @proxy_exercise.exercises.ransack.result.order(:title) #@search.result.order(:title)
end
#we might want to think about auth here

View File

@ -15,7 +15,7 @@ class RequestForCommentsController < ApplicationController
@search = RequestForComment
.last_per_user(2)
.with_last_activity
.search(params[:q])
.ransack(params[:q])
@request_for_comments = @search.result
.order('created_at DESC')
.paginate(page: params[:page], total_entries: @search.result.length)
@ -27,7 +27,7 @@ class RequestForCommentsController < ApplicationController
@search = RequestForComment
.with_last_activity
.where(user_id: current_user.id)
.search(params[:q])
.ransack(params[:q])
@request_for_comments = @search.result
.order('created_at DESC')
.paginate(page: params[:page])
@ -40,7 +40,7 @@ class RequestForCommentsController < ApplicationController
.with_last_activity
.joins(:comments) # we don't need to outer join here, because we know the user has commented on these
.where(comments: {user_id: current_user.id})
.search(params[:q])
.ransack(params[:q])
@request_for_comments = @search.result
.order('last_comment DESC')
.paginate(page: params[:page])

View File

@ -4,17 +4,17 @@ class StudyGroupsController < ApplicationController
before_action :set_group, only: MEMBER_ACTIONS
def index
@search = StudyGroup.search(params[:q])
@search = StudyGroup.ransack(params[:q])
@study_groups = @search.result.includes(:consumer).order(:name).paginate(page: params[:page])
authorize!
end
def show
@search = @study_group.users.search(params[:q])
@search = @study_group.users.ransack(params[:q])
end
def edit
@search = @study_group.users.search(params[:q])
@search = @study_group.users.ransack(params[:q])
@members = StudyGroupMembership.where(user: @search.result, study_group: @study_group)
end

View File

@ -106,7 +106,7 @@ class SubmissionsController < ApplicationController
end
def index
@search = Submission.search(params[:q])
@search = Submission.ransack(params[:q])
@submissions = @search.result.includes(:exercise, :user).paginate(page: params[:page])
authorize!
end