Rails 3 – html.erb中的表格
发布时间:2020-12-14 18:41:57 所属栏目:资源 来源:网络整理
导读:我想在视图中查看来自不同数据库表的数据,如下图所示: 我熟悉HTML标记 table, td和 tr,但我在列中遇到多个查询时遇到问题. table tr thSkills nbsp; nbsp; nbsp;/th thExpected-qualifications/th thCurrent-qualifications/th /tr % @employee.position.sk
我想在视图中查看来自不同数据库表的数据,如下图所示:
我熟悉HTML标记< table>,< td>和< tr>,但我在列中遇到多个查询时遇到问题. <table> <tr> <th>Skills </th> <th>Expected-qualifications</th> <th>Current-qualifications</th> </tr> <% @employee.position.skills.each do |skill| %><% @employee.position.expected_qualifications.each do |expected_qualification| %><% @employee.current_qualifications.each do |current_qualification| %> <tr> <td><%= skill.kategorien %></td> <td><%= expected_qualification.sollqualifikation %></td> <td><%= current_qualification.istqualifikation %></td> </tr> <% end %><% end %><% end %> </table> 此代码如下所示: 如您所见,技能,预期资格和当前资格重复. 我的问题:如何在表格中排序代码,以便它看起来像我想要的那样? 解决方法
试试
zip:
<% @employee.position.skills.zip(@employee.position.expected_qualifications,@employee.current_qualifications).each |skill expected_qualification current_qualification| %> <tr> <td><%= skill.kategorien %></td> <td><%= expected_qualification.sollqualifikation %></td> <td><%= current_qualification.istqualifikation %></td> </tr> <% end %> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |