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
Missing support for ActiveRecord::Enum (Rails 4.1) #102
Comments
@bryanrite, is there anything I can do to help with the process of reviewing my pull request for this issue? |
No.. sorry Mark, just been preoccupied with other things lately. Your PR looks good, I'll take a look at merging it tomorrow. |
Closing this in favour of #196 |
Thanks! Mark Mitchell
|
Bryan — It doesn’t look like you’ve had a chance to merge this PR yet. Is there anything I can do to help? Thank you, Mark Mitchell
|
Sorry Mark, been having a hard time finding hours to continuing heading CCC maintainership. Looking for a new maintainer if you're interested 😄 Check out: #209 |
Rails 4.1 introduced support for enums, represented by integers in the database. Currently, defining abilities matching enum values becomes tedious, as the actual enum value is required (for matching abilities on model instances) as well as the respective integer value (for matching abilities in database queries, i.e. accessible_by).
Example:
Checking the ability against an instance with
authorize! :read, @foobar
requires the'active'
value in the ability definition while fetching accessible foobars withFooBar.all.accessible_by(current_ability)
requires the actual integer value (given viaFooBar.states
).Maybe it is possible for CanCanCan to detect enum columns and extend the ability definition automatically.
The text was updated successfully, but these errors were encountered: