Starting from Rails 6.1, Action View now tries to call size on collection to find out the collection's size while it's building the
cursor. This causes a compatibility issue when you try to render ActiveHash::Relation as a collection object, as AH::R did not respond to #size.
Starting from Rails 6.1, Action View now tries to call
size
on collection to find out the collection's size while it's building the cursor. This causes a compatibility issue when you try to renderActiveHash::Relation
as a collection object, asAH::R
did not respond to#size
.Error message:
Example code that triggered the error:
Related code in Rails: https://github.com/rails/rails/blob/v6.1.1/actionview/lib/action_view/renderer/collection_renderer.rb#L47-L49
In this commit, I also switched
count
method to usealias_method
as bothcount
andsize
can be defined as an alias forlength
.