ubuntu, ror, jQuery, css, website memo
太嫩, 沒啥心得, 用來紀錄每天學的
2010年4月16日星期五
Practical Rails Social Networking Site memo (2)
#Ch10
module ApplicationHelper
def yes_no(bool)
...
end
def tag_cloud(tags, classes)
max, min = 0, 0
tags.each do |tag|
max = tag.count if tag.count > max
min = tag.count if tag.count < min
end
divisor = ((max - min) / classes.size) + 1
tags.each do |tag|
yield tag.name, classes[(tag.count - min) / divisor]
end
end
end
<% tag_cloud @tags, %w(tag1 tag2 tag3 tag4 tag5) do |name, css_class| %>
<%= link_to name, tag_path(name), :class => css_class %>
<% end %>
1 意見:
林守全
提到...
笑口常開~~天天開心
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
2010年4月19日上午10:53
張貼意見
較新的文章
較舊的文章
首頁
訂閱:
張貼意見 (Atom)
1 意見:
笑口常開~~天天開心........................................
張貼意見