我有一个带有嵌套属性 Property 的 Article 对象。现在我想在 show.html.erb 的前面打印它
我可以打印所有属性,但最后我得到一个输出,看起来像一个包含所有对象的地图。我究竟做错了什么?
显示.html.erb
<p>
<%= @article.properties.each do |property| %>
<li>
<b><%= property.name %></b> <%= property.value %>
</li>
<% end %>
</p>
文章.rb
class Article < ActiveRecord::Base
has_many :properties
accepts_nested_attributes_for :properties
end
以及浏览器中错误的 html 输出
Property_6588 Value_6588
Property_9390 Value_9390
Property_15367 Value_15367
Property_19710 Value_19710
[#<Property id: 6588, name: "Property_6588", value: "Value_6588", article_id: 4766, created_at: "2012-04-12 13:33:23", updated_at: "2012-04-12 13:33:23">, #<Property id: 9390, name: "Property_9390", value: "Value_9390", article_id: 4766, created_at: "2012-04-12 13:33:29", updated_at: "2012-04-12 13:33:29">, #<Property id: 15367, name: "Property_15367", value: "Value_15367", article_id: 4766, created_at: "2012-04-12 13:33:41", updated_at: "2012-04-12 13:33:41">, #<Property id: 19710, name: "Property_19710", value: "Value_19710", article_id: 4766, created_at: "2012-04-12 13:33:50", updated_at: "2012-04-12 13:33:50">]