Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

STI and ability definition #612

Closed
dgilperez opened this Issue · 1 comment

1 participant

@dgilperez

Hi!

I have this models:

class Variable < ActiveRecord::Base
end

class TextVariable < Variable
end

class VariableVariable < Variable
end

And my ability.rb looks like this:

class Ability
  include CanCan::Ability

  def initialize(user)

    can :manage, Variable do |variable|
      # some code
    end
  end
end

I was willing to define my ability to be defined on the parent class, and hoping the descendents to be assigned the same ability level. It's not working with that code.

Is there any way to achieve this behaviour?

Thanks !

@dgilperez dgilperez closed this
@dgilperez

After looking at the source code and realizing that this behaviour was actually implemented:

https://github.com/ryanb/cancan/blob/master/lib/cancan/rule.rb#L89

I doubled checked my code and catch the bug. Cancan is working as expected :) I leave the question for reference, since I didn't find much information about this on google.

Thanks Ryan for the great work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.