On Fri, May 14, 2010 at 12:22 AM, Neeraj Singh <[email protected]> wrote: > class Brake > scope :good, where(:quality => 'good') > end > > Brake.all.select &:nil? #=> works fine > Brake.good.select &:nil? #=> FAILS > > Last statement fails because Brake.good.select is returning > ActiveRecord::Relation and not an array. > > I have posted a detailed discussion on ticket #4589 . > https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/4589-issues-with-scopesassociation-proxies-lazyenum-behavior#ticket-4589-4 > > Would love to hear thoughts from others.
If you want to explicitly call an Array/Enumerable method on a Relation, convert it to one first, by using #to_a. I don't think this is a problem, just something that is expectable but you should remember. Cheers, -foca > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Core" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/rubyonrails-core?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
