Skip to content
Advertisement

Rails select() and count() don’t seem to play nice

I’ve noticed something odd with Rails (4.1) ActiveRecord, where select and count sometimes mix badly:

So far, so good. I can select on id:

Still good. I can also select on email:

But now problems begin. When I select on both id and email:

Why is it that count and size (which in this case aliases to count) are throwing an exception, and only when I select more than one attribute?

Is there an explanation for this? I find this quite unexpected.

Advertisement

Answer

This is a bug in Rails 4.1. See https://github.com/rails/rails/issues/13648

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement