HAML displays array after #each

I have the following HAML entry to replace the scaffold index page:

%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

When the page is displayed, the tables print as expected, but the @races array is subsequently printed; eg:

[#<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">]

Am I doing something wrong with the loop structure in HAML or what would make the array visualize?

+5
source share
1 answer

Tilde ( ~) prints the result of a string that is an array, since it Array#eachreturns the original array. =and ~act similarly in this sense; ~However, it retains spaces that are usually =separated.

, (-), , .

. HAML:)

+14

All Articles