[Rails-core] CollectionAssociation shadows Enumerable#count

2013-01-31 Thread Christian Romney
Hi all, I realize this behavior is by design, and in some respects the right thing to do. It also pre-dates the addition of Enumerable#count. I'm wondering, however, if it's possible/desirable to allow the caller to access the Enumerable versions under certain conditions. I originally wrote the

Re: [Rails-core] CollectionAssociation shadows Enumerable#count

2013-01-31 Thread Rafael Mendonça França
I'm not sure but this can add some confusion. I remember we removed the possibility to pass a block to sum and count to avoid confusion of users that may think the block will change the database query. On Jan 31, 2013 8:12 PM, "Christian Romney" wrote: > Hi all, > > I realize this behavior is by

Re: [Rails-core] CollectionAssociation shadows Enumerable#count

2013-02-01 Thread Matt Jones
On Jan 31, 2013, at 1:35 PM, Christian Romney wrote: > Hi all, > > I realize this behavior is by design, and in some respects the right thing to > do. It also pre-dates the addition of Enumerable#count. I'm wondering, > however, if it's possible/desirable to allow the caller to access the > E

Re: [Rails-core] CollectionAssociation shadows Enumerable#count

2017-05-15 Thread Matt Wean
I just ran into this issue, and I would actually call it a bug since it causes very unexpected behavior: > User.count { |user| user.not_a_method! } => 10 So the block isn't even being evaluated. I'm fine if we don't delegate to Enumerable, but I would expect #count to at least raise an error

Re: [Rails-core] CollectionAssociation shadows Enumerable#count

2017-05-15 Thread Miles Georgi
Agreed :+1: On Monday, May 15, 2017 at 10:18:07 PM UTC, Matt Wean wrote: > > I just ran into this issue, and I would actually call it a bug since it > causes very unex

Re: [Rails-core] CollectionAssociation shadows Enumerable#count

2017-05-15 Thread Omar Bohsali
Also agree with Matt Wean and Miles on this one. On Monday, May 15, 2017 at 3:33:26 PM UTC-7, Miles Georgi wrote: > > Agreed :+1: > > > > > > On Monday, May 15, 2017 at 1

Re: [Rails-core] CollectionAssociation shadows Enumerable#count

2017-05-16 Thread Jason Fleetwood-Boldt
I've never passed an argument to a .count method in my 9 years of writing ruby code. I would never think to do such a thing and such a thing would never occur to me (passing anything — block or otherwise — to a count method) Here's the efficiency problem with your code & proposal: > submissio

Re: [Rails-core] CollectionAssociation shadows Enumerable#count

2017-05-16 Thread Phillip Getto
I think this was merged into 5.1 (https://github.com/rails/rails/pull/24203). - Phil -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+un