【发布时间】:2016-09-27 20:28:28
【问题描述】:
我在表格中显示用户列表(无分页)。用户包含 id、姓名、年龄、状态、位置。我想允许按年龄或状态过滤列表。我如何在 ruby rails 中做到这一点?我尝试使用filterrific,但自从前两天卡住了here
Id name age status location
1 xz 22 single ca
2 yy 23 married ma
查看
<table>
<tr>
<th>id</th>
<th>name</th>
<th>age</th>
<th>status</th>
<th>location</th>
</tr>
<% items.each do |item| %>
<tr>
<td><%= item.id %></td>
<td><%= item.name %></td>
<td><%= item.age %></td>
<td><%= item.status %></td>
<td><%= item.lcation %></td>
</tr>
<% end %>
</table>
控制器
def index
@items = User.all
end
【问题讨论】:
-
你试过什么?您发布的教程非常直接地介绍了实现
-
我遵循了这一点,但我不确定我哪里出错了。我收到错误“未定义的方法页面”
标签: ruby-on-rails ruby filterrific