Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

17 lines (14 sloc) 0.448 kb
module ActsAsTaggableOn
module TagsHelper
# See the README for an example using tag_cloud.
def tag_cloud(tags, classes)
tags = tags.all if tags.respond_to?(:all)
return [] if tags.empty?
max_count = [tags.sort_by(&:count).last.count.to_f,1].max
tags.each do |tag|
index = ((tag.count / max_count) * (classes.size - 1))
yield tag, classes[index.nan? ? 0 : index.round]
end
end
end
end
Jump to Line
Something went wrong with that request. Please try again.