Adding Rails 4 support.

Rails 4 removes adds ActiveRecord::Result class and removes the `size`
method from it, so we need to use `count` instead.