I have in my database 3 records and i want that they looks like: if I using for (each)
<% @records.each do |record| %>
A row is several data banks (cells) laid out horizontally in a table or spreadsheet. For example, in the picture below, the row headers (row numbers) are numbered 1, 2, 3, 4, 5, etc. Row 16 is highlighted in red and cell D8 (on row 8) is the selected cell.
If you need a quick way to count rows that contain data, select all the cells in the first column of that data (it may not be column A). Just click the column header. The status bar, in the lower-right corner of your Excel window, will tell you the row count.
If you'd like to number each row in a result set, SQL provides the ROW_NUMBER() function. This function is used in a SELECT clause with other columns. After the ROW_NUMBER() clause, we call the OVER() function. If you pass in any arguments to OVER , the numbering of rows will not be sorted according to any column.
You probably want each_with_index
. something like:
<% @records.each_with_index do |record, i| %>
<%= (i+1) %>. <%= record.foo %> <br />
<% end %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With