【问题标题】:Ruby on rails: filtering search boxRuby on rails:过滤搜索框
【发布时间】:2014-12-15 14:14:46
【问题描述】:

我正在创建一个复制在线词典的 Rails 应用程序。我已经实现了Alphabetical_paginate gem,但是我想添加一个搜索栏,可以在您键入要查找的单词时过滤单词。是否有可以执行此操作的 gem,或者是否有使用搜索栏进行过滤的直接方法?

我的控制器如下所示:

def index
  @words, @alphaParams = Word.all.alpha_paginate(params[:letter], {:default_field => "all"}){|word| word.word}
end

查看:

<%= alphabetical_paginate @alphaParams %>

<table>
  <thead>
    <tr>
      <th>Word</th>
      <th>Wordtype</th>
      <th>Description</th>
      <th colspan="3"></th>
    </tr>
  </thead>

<div id="pagination_table">
  <tbody>
    <% @words.each do |word| %>
      <tr>
        <td><%= word.word %></td>
        <td><%= word.wordtype %></td>
        <td><%= word.description %></td>
        <td><%= link_to 'Show', word %></td>
      </tr>
    <% end %>
  </tbody>
</div>
</table>

【问题讨论】:

    标签: ruby-on-rails ruby search dictionary


    【解决方案1】:

    Datatables 正是您要找的。​​p>

    以下是开始使用的链接:

    1. http://datatables.net/
    2. https://github.com/rweng/jquery-datatables-rails

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-05-03
      • 2019-07-29
      • 2012-07-21
      • 2010-11-05
      • 1970-01-01
      • 1970-01-01
      • 2018-04-20
      • 1970-01-01
      相关资源
      最近更新 更多