Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update accessible by strategy validation #860

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions lib/cancan/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,14 @@ def self.with_accessible_by_strategy(value)
end
end

def self.validate_accessible_by_strategy!(value)
return if valid_accessible_by_strategies.include?(value)

raise ArgumentError, "accessible_by_strategy must be one of #{valid_accessible_by_strategies.join(', ')}"
def self.validate_accessible_by_strategy!(value)
unless value < CanCan::ModelAdapters::Strategies::Base
raise ArgumentError, "Invalid strategy: #{value}. It should extend CanCan::ModelAdapters::Strategies::Base."
end

return if valid_accessible_by_strategies.include?(value)
end

def self.does_not_support_subquery_strategy?
!defined?(CanCan::ModelAdapters::ActiveRecordAdapter) ||
CanCan::ModelAdapters::ActiveRecordAdapter.version_lower?('5.0.0')
Expand Down