Skip to content

STI and ability definition #612

dgilperez opened this Issue Apr 29, 2012 · 1 comment

1 participant



I have this models:

class Variable < ActiveRecord::Base

class TextVariable < Variable

class VariableVariable < Variable

And my ability.rb looks like this:

class Ability
  include CanCan::Ability

  def initialize(user)

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

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 Apr 29, 2012

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

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.