I got an issue with cancancan gem and inherited tables on Ruby on rails.
My account model has multiple inherited models Teacher < Account
, Director < Account
which have different abilities.
Here are my rules: "in ability.rb"
if account.director?
can :manage, Account, profile: [ :teacher, :director ]
end
if account.teacher?
can :manage, Account, profile: [ :teacher ]
end
My route file looks like:
resources :directors, controller: :accounts, profile: :director
resources :teachers, controller: :accounts, profile: :teacher
When I'm logged in as a teacher and I go to /directors (index page), Cancan should raise a Unauthorized::AccessDenied message instead of displaying the directors page.
I probably missed something in the doc. Is someone could enlighten me?
Thanks