I am trying to count # objects in an array using a block, for example:
cc = u.cookies.count {|n| n.opened}
This is return 3, which is incorrect. I took another step and did the following:
cc = u.cookies.count {|n| false}
which should always return 0, but it returns 3 !!!.
This is returning 0, as it should:
[1,2,3,4].count {|n| false}
Here is my user model:
class User < ActiveRecord::Base has_many :cookies end
What's happening? Thanks
source share