20140409

limit tag cloud with acts_as_taggable_on

Now that I'm having around 300 recipes (just testing recipes, the final count would be more than 10k), I was having some issues with the tags. The tag list was quite big and each new tag was added to the tag cloud.

So I searched for any nice solution, but all was quite messy. The solution was really simple.

To limit the tag-cloud, having something like:



  <% tag_cloud(Model.tag_counts, %w[s m l]) do |tag, css_class| %>
    <%= link_to tag.name, tag_path(tag.name), class: css_class %>
  <% end %>


The solution is something like:


  <% tag_cloud(Model.tag_counts.limit(30), %w[s m l]) do |tag, css_class| %>
    <%= link_to tag.name, tag_path(tag.name), class: css_class %>
  <% end %>

But almost all the solutions on the web makes changes in the controller, models and so on, but almost all that solutions adds more things than the simple answer to the problem

No hay comentarios.: