From 5445ac9c6fbcc000b4af3ff275ea2834b59c7fc6 Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Thu, 12 Sep 2019 04:01:19 +0500 Subject: [PATCH] Add attribute ApplicationPolicy::Context#params --- app/controllers/application_controller.rb | 1 + app/policies/application_policy.rb | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 01bd2c4..83917e4 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -24,6 +24,7 @@ private def pundit_user @pundit_user ||= ApplicationPolicy::Context.new( account: current_account, + params: params, ) end diff --git a/app/policies/application_policy.rb b/app/policies/application_policy.rb index 06781a3..ae8931c 100644 --- a/app/policies/application_policy.rb +++ b/app/policies/application_policy.rb @@ -50,6 +50,10 @@ private context&.account end + def params + context&.params + end + def restricted? Rails.application.restricted? end @@ -76,16 +80,21 @@ private context&.account end + def params + context&.params + end + def restricted? Rails.application.restricted? end end class Context - attr_reader :account + attr_reader :account, :params - def initialize(account:) + def initialize(account:, params:) @account = account + @params = params end end end