【发布时间】:2011-01-31 04:36:22
【问题描述】:
警告我是 Rails 的新手! 在阅读教程时,它要求我将带有十进制值的字符串键的哈希值放入 products 操作方法中(我假设他们正在谈论控制器中的“def products”。
在控制器中使用 products 方法时,我是否正确放置了哈希? 关于将信息从散列放入表中,我什至需要帮助方法还是有更好的方法? 我的助手需要帮助,但没有使用 .html_safe I 正确格式化数据
这是我迄今为止在我的控制器中所拥有的:
def products
#hard coded as products in controller
@stuff = {"a"=>200.00, "b"=>150.00, "c"=>100.00, "d"=>9.00, "e"=>15.00, "f"=>20.00 }
end
这是我的 product.html.erb 文件中的内容
<%= form_tag(products_path) do %>
<table id="aboutus_table">
<%= products_tabler() %>
</table>
<% end %>
然后是助手……它需要帮助
def products_tabler
snowholder = @snow_stuff.each {|key,value|puts "<tr><td>#{key}</td><td>#{value}</td><tr>"}
return snowholder
end
【问题讨论】:
标签: ruby-on-rails ruby