У меня есть контроллер, Players :: SearchesController
class Players::SearchesController < ApplicationController
def index
@q = Player.ransack(search_params[:q])
@players = Player.none
end
def create
# This executes when I initiate a ransack search
end
private
def search_params
params.permit(:utf8, :commit, :search_type, :current_user_id, :q)
params.require(:q).permit!
end
end
Я использую его без какой-либо модели, связанной с ним.Я пытаюсь использовать его с Ransack, но я продолжаю получать следующую ошибку в моем терминале при запуске поиска.Я не могу понять, как получить параметр «q», который будет разрешен.
(byebug) search_params
Unpermitted parameter: :q
<ActionController::Parameters {"position_id_in"=>["", "5"], "draft_year_in"=>["", "2019"], "measurable_summary_height_gteq"=>"5080", "measurable_summary_height_lteq"=>"5080", "measurable_summary_weight_gteq"=>"", "measurable_summary_weight_lteq"=>"", "measurable_summary_speed_gteq"=>"", "measurable_summary_speed_lteq"=>"", "measurable_summary_ten_yard_dash_gteq"=>"", "measurable_summary_ten_yard_dash_lteq"=>"", "measurable_summary_test_gteq"=>"", "measurable_summary_test_lteq"=>"", "measurable_summary_hand_span_gteq"=>"", "measurable_summary_hand_span_lteq"=>"", "measurable_summary_arm_length_gteq"=>"", "measurable_summary_arm_length_lteq"=>"", "measurable_summary_vertical_jump_gteq"=>"", "measurable_summary_vertical_jump_lteq"=>"", "measurable_summary_bench_reps_gteq"=>"", "measurable_summary_bench_reps_lteq"=>""} permitted: true>
Вот то, из чего состоит и мой params
объект ...
<ActionController::Parameters {"utf8"=>"✓", "q"=><ActionController::Parameters {"position_id_in"=>["", "5"], "draft_year_in"=>["", "2019"], "measurable_summary_height_gteq"=>"5080", "measurable_summary_height_lteq"=>"5080", "measurable_summary_weight_gteq"=>"", "measurable_summary_weight_lteq"=>"", "measurable_summary_speed_gteq"=>"", "measurable_summary_speed_lteq"=>"", "measurable_summary_ten_yard_dash_gteq"=>"", "measurable_summary_ten_yard_dash_lteq"=>"", "measurable_summary_test_gteq"=>"", "measurable_summary_test_lteq"=>"", "measurable_summary_hand_span_gteq"=>"", "measurable_summary_hand_span_lteq"=>"", "measurable_summary_arm_length_gteq"=>"", "measurable_summary_arm_length_lteq"=>"", "measurable_summary_vertical_jump_gteq"=>"", "measurable_summary_vertical_jump_lteq"=>"", "measurable_summary_bench_reps_gteq"=>"", "measurable_summary_bench_reps_lteq"=>""} permitted: true>, "search_type"=>"measurables", "commit"=>"Search", "controller"=>"players/searches", "action"=>"create"} permitted: false>
Что я здесь делаю неправильно?