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

Missing support for ActiveRecord::Enum (Rails 4.1) #102

Closed
tbk303 opened this issue Jul 24, 2014 · 6 comments
Closed

Missing support for ActiveRecord::Enum (Rails 4.1) #102

tbk303 opened this issue Jul 24, 2014 · 6 comments

Comments

@tbk303
Copy link

tbk303 commented Jul 24, 2014

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:

can :read, FooBar, state: ['active', FooBar.states['active']]

Checking the ability against an instance with authorize! :read, @foobar requires the 'active' value in the ability definition while fetching accessible foobars with FooBar.all.accessible_by(current_ability) requires the actual integer value (given via FooBar.states).

Maybe it is possible for CanCanCan to detect enum columns and extend the ability definition automatically.

@markpmitchell
Copy link
Contributor

@bryanrite, is there anything I can do to help with the process of reviewing my pull request for this issue?

@bryanrite
Copy link
Member

No.. sorry Mark, just been preoccupied with other things lately. Your PR looks good, I'll take a look at merging it tomorrow.

@bryanrite
Copy link
Member

Closing this in favour of #196

@markpmitchell
Copy link
Contributor

Thanks!

Mark Mitchell

On Apr 16, 2015, at 7:38 AM, Bryan Rite notifications@github.com wrote:

No.. sorry Mark, just been preoccupied with other things lately. Your PR looks good, I'll take a look at merging it tomorrow.


Reply to this email directly or view it on GitHub #102 (comment).

@markpmitchell
Copy link
Contributor

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

On Apr 16, 2015, at 10:37 AM, Mark Mitchell mark.patrick.mitchell@gmail.com wrote:

Thanks!

Mark Mitchell

On Apr 16, 2015, at 7:38 AM, Bryan Rite <notifications@github.com mailto:notifications@github.com> wrote:

No.. sorry Mark, just been preoccupied with other things lately. Your PR looks good, I'll take a look at merging it tomorrow.


Reply to this email directly or view it on GitHub #102 (comment).

@bryanrite
Copy link
Member

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

Senjai pushed a commit to Senjai/cancancan that referenced this issue Oct 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants