i am trying to count an # of objects in an array using a block, like this:
cc = u.cookies.count {|n| n.opened}
This return 3, which is wrong. I went a step further, and did this:
cc = u.cookies.count {|n| false}
which should always return 0, but it returns 3!!!.
This return 0, just like it should:
[1,2,3,4].count {|n| false}
Here's my user model:
class User < ActiveRecord::Base
has_many :cookies
end
What's going on? Thanks