How to sort alphabetically tag_list in act_as_taggable_gem?

55 Views Asked by At

I built podcasts page and installed acts_as_taggable_on gem.

in index page, the page shows all the list of podcast items along with the tag_list.

I want to show the tag_list in alphabetical order, but it shows as the order of creation.

How can I approach this?

I found a way online and tried but getting an error.(below code)

=podcast.tag_list.sort{ |x, y| x.name.upcase <=> y.name.upcase }.join(' | ')

 undefined method `name' for "Two":String

enter image description here

Current working code is =podcast.tag_list.join(' | ')

0

There are 0 best solutions below