我编写了以下HAML代替脚手架索引页面:
%h1 Listing Races
%table
%tr
%th Name
%th Date
%th Details
~@races.each do |race|
%tr
%td= race.name
%td= race.date
%td= race.details
%td= link_to 'Show', race
%td= link_to 'Edit', edit_race_path(race)
%td= link_to 'Destroy', race, :confirm => 'Are you sure?', :method => :delete
%br
= link_to 'New Race', new_race_path
Run Code Online (Sandbox Code Playgroud)
在渲染页面时,表格按预期打印出来,但之后也会打印数组@races; 例如:
[#<Race id: 1, name: "TestRace15", date: "2011-03-11 11:00:00", details: "Test Race to make sure that everything seems to wor...", created_at: "2011-03-03 00:16:09", updated_at: "2011-03-03 00:16:09">]
Run Code Online (Sandbox Code Playgroud)
我是否在HAML中对循环结构做错了什么,或者是什么导致数组被渲染?
haml ×1