【问题标题】:how to filter table by column in ruby rails如何在ruby rails中按列过滤表格
【发布时间】: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


【解决方案1】:

我认为,this cast 可以帮助您在没有任何宝石的情况下达到完美。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-08-16
    • 1970-01-01
    • 2011-03-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多