Difference between count, length and size in an association with ActiveRecord

With Rails/ActiveRecord, you can count the records in an association using three methods .count, .length, .size.As a rails newbie, when you first discover this, it can be confusing… Why do we need three methods? Is there any advantage to using one method over the other? How are they different?Here are 6 characteristics of this three methods that you should know. They will help you decide which method to use on different situations.I will also share a why I think that most of the time you should start with .size and the reference to the docs where you can find more information.
Difference between count, length and size in an association with ActiveRecord #ruby #rubydeveloper #rubyonrails #activerecord https://rubyonrails.ba/single/difference-between-count-length-and-size-in-an-association-with-activerecord

Nezir Zahirovic

Contractor Ruby On Rails (8+ years) / MCPD .Net / C# / Asp.Net / CSS / SQL / (11 years)

related articles