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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With