CanCanCommunity / cancancan

The authorization Gem for Ruby on Rails.
MIT License
5.55k stars 637 forks source link

Undefined Method exception when block is passed with curly braces #720

Open mateusfdl opened 3 years ago

mateusfdl commented 3 years ago

when:

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

CanCan handle undefined method exception (undefined method Note' for # )

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

siax84 commented 1 year ago

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

MarkMT commented 1 month ago

I experienced the same problem - Rails 6.0. Thanks for the pointer. do...end works, and I would not have thought to try it.