Is possible CanCan can :manage, :all except one or more method?

Bruno Sapienza picture Bruno Sapienza · May 10, 2013 · Viewed 7.1k times · Source

I'm doing:

can :manage, :all if user.role == 'admin'

can :approve, Anuncio do |anuncio|
  anuncio.try(:aprovado) == false
end

My second method does not work because the :manage :all override it. Theres a way to declare can manage all except approve? and inside approve i just do

can :approve, Anuncio do |anuncio|
  user.role == 'admin' && anuncio.try(:aprovado) == false
end

What's the better solution?

Answer

Lucas picture Lucas · May 10, 2013

Try do it another way round, look into cancan wiki. Try:

can :manage, :all if user.role == 'admin'

cannot :approve, Anuncio do |anuncio|
  anuncio.try(:aprovado)
end