'stack level too deep' while executing .exists? on restricted object

86 Views Asked by At

lets say we have a post with many comments.

when i try to do

post.restrict!(current_user).comments.exists?

it fails with:

SystemStackError: stack level too deep
from /Users/lord_HX/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/pry-.9.12.6/lib/pry/pry_instance.rb:328

i have changed my post.rb to simple

protect do |(current_user, current_account), project|
  can :read
end

but it still fails...

It looks like it infinitely executes exists? method from /protector-0.7.6/lib/protector/adapters/active_record/relation.rb

so i'm looking for any suggestion how to avoid this problem...

0

There are 0 best solutions below