Module: Blog::PostsHelper

Defined in:
app/helpers/blog/posts_helper.rb

Instance Method Summary collapse

Instance Method Details

#tag_cloud(tags, classes) ⇒ Object



7
8
9
10
11
12
13
# File 'app/helpers/blog/posts_helper.rb', line 7

def tag_cloud(tags, classes)
  max = tags.sort_by(&:count).last
  tags.each do |tag|
    index = tag.count.to_f / max.count * (classes.size-1)
    yield(tag, classes[index.round])
  end
end


3
4
5
# File 'app/helpers/blog/posts_helper.rb', line 3

def tag_links(tags)
  tags.split(",").map{|tag| link_to tag.strip, list_blog_posts_path(tag:tag.strip) }.join(", ")
end