Skip to content

Allow use of null values in enums on active record 5#833

Open
jtagle2 wants to merge 1 commit into
CanCanCommunity:developfrom
jtagle2:develop
Open

Allow use of null values in enums on active record 5#833
jtagle2 wants to merge 1 commit into
CanCanCommunity:developfrom
jtagle2:develop

Conversation

@jtagle2

@jtagle2 jtagle2 commented Oct 10, 2023

Copy link
Copy Markdown

Currently, if you have enum with null values, it fails the validation on CanCanCan because it casts the values received on the condition to strings, but the values that comes from the subject are not casted. This PR tries to manage that case, because nil in ruby is casted to the empty string, so if you have a condition like can action, model, enum_attribute: [null, :value], on the accessible_by it works correctly for rows with null value, but when doing the can? on a specific record, it fails if it has null value.

@jtagle2 jtagle2 force-pushed the develop branch 3 times, most recently from a3f9f3e to ff43b72 Compare October 10, 2023 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant