在数组上使用 .each 精简 Rails 个表
Slim Rails Tables Using .each Over an Array
当我将 = list.title
放在 tr
元素上方时,我的 table 工作正常,但是当我将它移到下面的 td
单元格中时,我得到一个 undefined method
列表错误。我是苗条和模板引擎的新手。你能建议如何正确格式化吗?在 slim 上还有完整的语法指南吗?我试着 Google 四处寻找,但找不到我想要的东西。
table
thead
tr
th
| Title
th
| Description
th
| Image URL
th
| Price
tbody
- @products.each do |list|
tr
td
= list.title
td
= list.description
td
= list.image_url
嗯,有缩进问题。您应该在其中包含 tr
标记及其子标记 indent
。即 - @products.each do |list|
应包含项目。
- @products.each do |list|
tr
td
= list.title
td
= list.description
td
= list.image_url
当我将 = list.title
放在 tr
元素上方时,我的 table 工作正常,但是当我将它移到下面的 td
单元格中时,我得到一个 undefined method
列表错误。我是苗条和模板引擎的新手。你能建议如何正确格式化吗?在 slim 上还有完整的语法指南吗?我试着 Google 四处寻找,但找不到我想要的东西。
table
thead
tr
th
| Title
th
| Description
th
| Image URL
th
| Price
tbody
- @products.each do |list|
tr
td
= list.title
td
= list.description
td
= list.image_url
嗯,有缩进问题。您应该在其中包含 tr
标记及其子标记 indent
。即 - @products.each do |list|
应包含项目。
- @products.each do |list|
tr
td
= list.title
td
= list.description
td
= list.image_url