【发布时间】:2015-10-08 13:40:44
【问题描述】:
我的助手中有这个:
def favorites_count(node)
content_tag :span, class: "card-favorite-count" do
content_tag :i, class: "icon-heart"
node.cached_votes_total
end
end
在视图中是这样调用的:
<%= favorites_count(node) %>
这就呈现了:
<span class="card-favorite-count"></span>
如何让它渲染整个东西?
编辑 1
根据@tolgap 下面的建议,我尝试了这个:
def favorites_count(node)
content_tag :span, class: "card-favorite-count" do
content_tag(:i, "" ,class: "icon-heart") + node.cached_votes_total
end
end
但这不会输出node.cached_votes_total 中的数值。它会输出其他所有内容,并以正确的语义顺序输出。这只是最后一部分还没有完全奏效。
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-4 helpers