We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Adding a can rule to authorize when a value is nil fails to authorize.
can
nil
class Person < ActiveRecord::Base enum my_enum: { 'something' => 0, 'other' => 1 } end class TestAbility include CanCan::Ability def initialize # can [:create], Person, my_enum: nil # also fails can [:create], Person, my_enum: [nil] end end TestAbility.new().can? :create, Person.new()
The bug is caused by this line because nil becomes ''
''
This would fix it
array_values = Array(value).map{|v| v.nil? ? nil : v.to_s } !(array_values & [attribute, raw_attribute]).empty?
Should return true
Returns false
Rails version: 6.1.0
Ruby version: 2.7.4
CanCanCan version 3.2.0
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Steps to reproduce
Adding a
can
rule to authorize when a value isnil
fails to authorize.The bug is caused by this line because
nil
becomes''
This would fix it
Expected behavior
Should return true
Actual behavior
Returns false
System configuration
Rails version:
6.1.0
Ruby version:
2.7.4
CanCanCan version
3.2.0
The text was updated successfully, but these errors were encountered: