ActiveAdmin& PgSearch

时间:2014-11-25 10:31:57

标签: ruby-on-rails-4 activeadmin pg-search

抱歉我的英文。我遇到问题:如何将pg_search用于activeadmin?

我用:

activeadmin 1.0.0.pre

我试图这样做:

class User < ActiveRecord::Base
  ...
  include PgSearch
  pg_search_scope :search2, against: :name

  ransacker :name,
    formatter: proc { |e|
      results = User.search2(e).map(&:id)
      results.present? ? results : nil
    }, splat_params: true do |parent|
    parent.table[:id]
  end
  ...
end

在ActiveAdmin中:

ActiveAdmin.register User do
  ...
  filter :name_in, :as => :string, :label => 'Name'
  ...
end

这很有效,但是当我搜索记录时:

之前的

http://i.stack.imgur.com/s1RSt.png

http://i.stack.imgur.com/wHIQG.png

0 个答案:

没有答案