From 1ab5bd488c5d0766cab59c892ec492e8a7f2c1b2 Mon Sep 17 00:00:00 2001 From: Taketo Takashima Date: Mon, 20 Jan 2025 10:28:08 +0900 Subject: [PATCH] Replace to use of ActionController::Parameters#expect for strong parameter --- .rubocop.yml | 2 ++ Gemfile.lock | 4 ++-- app/controllers/diagnosis_logs_controller.rb | 2 +- app/controllers/ignore_error_results_controller.rb | 2 +- app/controllers/log_campaigns_controller.rb | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index f9d86d4..332fea7 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -6,3 +6,5 @@ inherit_gem: { rubocop-rails-omakase: rubocop.yml } # # Use `[a, [b, c]]` not `[ a, [ b, c ] ]` # Layout/SpaceInsideArrayLiteralBrackets: # Enabled: false +Rails/StrongParametersExpect: + Enabled: true diff --git a/Gemfile.lock b/Gemfile.lock index 391baf9..6321746 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -147,7 +147,7 @@ GEM foreman (0.88.1) globalid (1.2.1) activesupport (>= 6.1) - i18n (1.14.6) + i18n (1.14.7) concurrent-ruby (~> 1.0) io-console (0.8.0) irb (1.14.3) @@ -322,7 +322,7 @@ GEM rubocop-performance (1.23.1) rubocop (>= 1.48.1, < 2.0) rubocop-ast (>= 1.31.1, < 2.0) - rubocop-rails (2.28.0) + rubocop-rails (2.29.0) activesupport (>= 4.2.0) rack (>= 1.1) rubocop (>= 1.52.0, < 2.0) diff --git a/app/controllers/diagnosis_logs_controller.rb b/app/controllers/diagnosis_logs_controller.rb index ca1224d..c58965d 100644 --- a/app/controllers/diagnosis_logs_controller.rb +++ b/app/controllers/diagnosis_logs_controller.rb @@ -80,6 +80,6 @@ def set_diagnosis_log # Never trust parameters from the scary internet, only allow the white list through. def diagnosis_log_params - params.require(:diagnosis_log).permit(:layer, :log_group, :log_type, :target, :log_campaign_uuid, :result, :detail, :occurred_at) + params.expect(diagnosis_log: [ :layer, :log_group, :log_type, :target, :log_campaign_uuid, :result, :detail, :occurred_at ]) end end diff --git a/app/controllers/ignore_error_results_controller.rb b/app/controllers/ignore_error_results_controller.rb index 93701e7..d928430 100644 --- a/app/controllers/ignore_error_results_controller.rb +++ b/app/controllers/ignore_error_results_controller.rb @@ -92,6 +92,6 @@ def set_ignore_error_result # Never trust parameters from the scary internet, only allow the white list through. def ignore_error_result_params - params.require(:ignore_error_result).permit(:ssid, ignore_log_types: []) + params.expect(ignore_error_result: [ :ssid, ignore_log_types: [] ]) end end diff --git a/app/controllers/log_campaigns_controller.rb b/app/controllers/log_campaigns_controller.rb index 26881b3..b5103b7 100644 --- a/app/controllers/log_campaigns_controller.rb +++ b/app/controllers/log_campaigns_controller.rb @@ -135,6 +135,6 @@ def set_log_campaign # Never trust parameters from the scary internet, only allow the white list through. def log_campaign_params - params.require(:log_campaign).permit(:log_campaign_uuid, :ssid, :network_type, :mac_addr, :os, :version, :occurred_at) + params.expect(log_campaign: [ :log_campaign_uuid, :ssid, :network_type, :mac_addr, :os, :version, :occurred_at ]) end end