Rails:一次加载两个表格单元格
这看起来应该很容易,但我想不出办法。本质上,我想加载(在 ERB 中,从通过 Rails 获取的集合)一个包含单元格的 HTML 表,这样第一行有前两条记录,第二行有接下来的两条记录,等等。像这样
-----------
| 1 | 2 |
| 3 | 4 |
| 5 | 6 |
-----------
:是一种一次迭代两个记录的集合的 Ruby/Rails 方法。
This seems like it should be easy, but I can't figure out a way to do it. Essentially I want to load (in ERB, from a collection fetched via Rails) an HTML table with cells such that the first row has the first two records, the second row has the next two, etc. Something like this:
-----------
| 1 | 2 |
| 3 | 4 |
| 5 | 6 |
-----------
Seems like there would be a Ruby/Rails way to iterate over a collection two records at a time.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
啊,在 这个问题。
为了后代的利益,这是我的解决方案:
Ah, figured it out moments after posting, with help from this question.
For posterity's sake, here's my solution: