RailsCasts Pro episodes are now free!

Learn more or hide this

Oren Dobzinski's Profile

GitHub User: orend

Comments by Oren Dobzinski

Avatar

You probably want to replace

ruby
max = tags.sort_by(&:count).last

with

ruby
max = tags.max_by(&:count)

There's no need to sort the array only to pick the largest element.