cancancan icon indicating copy to clipboard operation
cancancan copied to clipboard

Undefined Method exception when block is passed with curly braces

Open mateusfdl opened this issue 3 years ago • 2 comments

when:

can :update, Note { |note| note.writer_id == user.id }

CanCan handle undefined method exception (undefined method Note' for #Abilities::ExampleAbilitie:0x000055d5ebc6fe50 )

when:

can :update, Note do |note| note.writer_id == user.id end

works fine

System configuration

Rails version:

6.1.3.2

Ruby version:

2.6.4

CanCanCan version

3.2.0

mateusfdl avatar Jul 12 '21 19:07 mateusfdl

Can't help, but find your post very useful nonetheless. I was looking in the docs if passing a block is at all possible and couldn't find anything. I'm fine with writing do ... end

siax84 avatar Nov 24 '22 10:11 siax84