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 up as an issue, but was informed this would be the better venue. I''m linking to the original issue on Github because the syntax highlighting is nice. https://github.com/rails/rails/issues/9132 TIA for taking the time to think this over. -- 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+unsubscribe@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Rafael Mendonça França
2013-Jan-31 22:45 UTC
Re: CollectionAssociation shadows Enumerable#count
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" <xmlblog@gmail.com> 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 > Enumerable versions under certain conditions. I originally wrote the up > as an issue, but was informed this would be the better venue. I''m linking > to the original issue on Github because the syntax highlighting is nice. > > https://github.com/rails/rails/issues/9132 > > TIA for taking the time to think this over. > > -- > 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+unsubscribe@googlegroups.com. > To post to this group, send email to rubyonrails-core@googlegroups.com. > Visit this group at http://groups.google.com/group/rubyonrails-core?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > >-- 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+unsubscribe@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
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 Enumerable versions under certain conditions. I originally wrote the up as an issue, but was informed this would be the better venue. I''m linking to the original issue on Github because the syntax highlighting is nice. > > https://github.com/rails/rails/issues/9132In the example in the issue, wouldn''t this work nearly as well: def incomplete_submissions submissions.to_a.count(&:incomplete?) end In short, if you want the Enumerable behavior, just ask for it... --Matt Jones -- 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+unsubscribe@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core?hl=en. For more options, visit https://groups.google.com/groups/opt_out.