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?
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