From f55ce37d3d28d7c18b8458b657431bb7c07ac4a1 Mon Sep 17 00:00:00 2001 From: Alessandro Desantis Date: Thu, 8 Oct 2020 16:38:22 +0200 Subject: Add scope to subscription permissions With an AR scope, `#accessible_by` can be properly used. --- lib/solidus_subscriptions/permission_sets/subscription_management.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/solidus_subscriptions/permission_sets') diff --git a/lib/solidus_subscriptions/permission_sets/subscription_management.rb b/lib/solidus_subscriptions/permission_sets/subscription_management.rb index c669368..9077ab9 100644 --- a/lib/solidus_subscriptions/permission_sets/subscription_management.rb +++ b/lib/solidus_subscriptions/permission_sets/subscription_management.rb @@ -4,7 +4,7 @@ module SolidusSubscriptions module PermissionSets class SubscriptionManagement < ::Spree::PermissionSets::Base def activate! - can :manage, Subscription do |subscription, guest_token| + can :manage, Subscription, Subscription.where(user: user) do |subscription, guest_token| (subscription.guest_token.present? && subscription.guest_token == guest_token) || (subscription.user && subscription.user == user) end -- cgit v1.2.3