When you do ActiveRecord query such as

the_list = Phone.joins(:beeps).where(["(beeps.store_id = ?) AND (userphone LIKE ?)", @store.id, "%#{submitted_phone}"])

the_list.count and the_list.length both return the integer # of records found, although .count results in an additional query against the database.

However, if you add a .group(:userphone), then the_list.count returns a hash of unique userphones => counts, while the_list.length returns the integer number of unique userphone found.