Sort tag cloud alphabetically in act_as_taggable_on_steroids

I got the actions_as_taggable_on_steroids plugin to work fine. The tag_cloud method, in my opinion, correctly creates and formats the cloud, however the tags are listed in the order of "count desc".

How to present my tags in the cloud in alphabetical order?

+3
source share
1 answer

Here is what I do on my site to sort my tags by name:

<% tag_cloud Post.tag_counts.sort { |x, y| x.name <=> y.name }, %w(x-small small normal large x-large) do |tag, css_class| %>
  <%= link_to tag.name, tag_url( :tag => tag.name ), :class => css_class %>
<% end %>
+3
source

Source: https://habr.com/ru/post/1698597/


All Articles