ruby-on-rails - 在 Ruby on Rails 中创建大型引导表
问题描述
嗨,我对 Ruby on Rails 有点陌生,这应该很简单。我想制作一个大型引导表,同时还能够遍历我的模型/数据库表。
<table class="table">
<thead>
<tr>
<th scope="col">I</th>
<th scope="col">Id</th>
<th scope="col">Time</th>
<th scope="col">Duration</th>
<th scope="col">Price</th>
<th scope="col">Name</th>
<th scope="col">Company</th>
<th scope="col">City</th>
</tr>
</thead>
<tbody>
<% 96.times |i| %>
<% @workorders.each do |workorder| %>
<tr>
<td><%= i %></td>
<td><%= workorder.id %></td>
<td><%= workorder.time %></td>
<td><%= workorder.duration %></td>
<td><%= workorder.price %></td>
<td><%= workorder.name %></td>
<td><%= workorder.company %></td>
<td><%= workorder.city %></td>
</tr>
<% end %>
<% end %>
</tbody>
</table>
</div>
我已经验证,当我只进行一个.each
循环时,@workorders
它可以正常工作。然而,当我用上面的代码运行我的 Rails 应用程序时,我得到一个语法错误,没有什么太详细的了。创建这个 96 长度的引导表的正确语法是什么,同时还遍历我的模型/sqlite 表?
解决方案
杰出的!太感谢了!添加do
后96.times
解决了所有问题。
推荐阅读
- c++ - 将 CUDA 与从子目录添加为外部项目的项目链接
- jenkins - 使用通用 webhook 插件拉取基于 jenkins 作业的请求
- scala - 是否可以在 io bundle 中声明条件信号?
- swagger - 在环回中大摇大摆地隐藏一些请求参数/查询参数和响应模式字段
- python - 通过 keras API 保存 tensorflow 2.0 模型时发出警告
- envoyproxy - 配置特使以跳过特定 http 路由上的 mTLS
- azure - 为我的 SAAS 应用程序实施 SSO 服务提供程序并与 Azure AD SAML 集成
- javascript - 制表库和撤销功能
- python-3.x - 代码在计算最大连续 1 时失败 4/9 案例,我该如何改进?
- mongodb - MongoDB在聚合中使用唯一键忽略重复文档