我正在尝试创建一个助手来根据模型属性显示评级星。
我有以下内容:
def show_profile_stars(profile)
content_tag :span, :class => 'stars' do
profile.stars.times do
image_tag("stars.gif", :size => "30x30", :class => "gold")
end
end
end
'stars' 是一个整数字段。
但它不是渲染图像标签,而是按字面意思显示“星星”数字。
如果我只放了 image_tag 而没有迭代块,它确实显示了图像,那么问题出在迭代上。
我想我错过了一些关于接收块的方法(我还是 RoR 的新手)。
有什么帮助吗?
谢谢!