Gem 有支持多条件搜索的 GEM 吗?

luoyegufei · August 19, 2014 · Last by zouchaoge replied at April 28, 2015 · 2376 hits

搜索条件太多,如果去匹配每一个条件的话,代码量太大不好维护,有适合这种多条件搜索的 gem 吗?

手写的哭了

rails2 就用 searchlogic rails3 以上 rd_searchlogic meta_search 还有一个跟 meta_search 很像的,忘了叫啥

#1 楼 @bydmm 我需要用这个 ransack,但是作为一个初学者还是不大熟悉如何去使用,能介绍一下使用 ransack 的详细步骤吗?

#5 楼 @luoyegufei

前不久做的教会联系人管理系统,查找联系人页面用到了 ransack,很简单,你可以看一下: https://github.com/ZPVIP/church

肥 Controller: https://github.com/ZPVIP/church/blob/master/app/controllers/contacts_controller.rb

View: https://github.com/ZPVIP/church/blob/master/app/views/contacts/index.html.erb

meta-search

#10 楼 @Peter 我用了 ransack,但是报错说 result 未定义,这是什么情况呢?

#10 楼 @Peter 我的 model 中有 search 方法覆盖了 controller 里面的 search,这个时候应该怎解决呢?

#13 楼 @luoyegufei YourModel.ransack(params[:q])

You need to Sign in before reply, if you don't have an account, please Sign up first.