rails 3 search plugin

 

  gem "meta_search"
http://metautonomo.us/2010/03/07/metasearch-object-based-searching-for-rails-3/

this is good
http://metautonomo.us/projects/metawhere/

Debug your SQL with debug_sql

The to_sql method is a handy way to show your query, but as I’ve written about before, it has its shortcomings. When your query is going to eager load some records and has conditions referencing the eager loaded tables, ActiveRecord changes its generated query, but to_sql is none the wiser. Enter debug_sql:

 

ruby-1.9.2-head > Article.includes(:comments).where(:comments => {:body => 'hey'}).to_sql
 => SELECT "articles".* FROM "articles" WHERE ("comments"."body" = 'hey')
#
# LIES!!!
#
ruby-1.9.2-head > Article.includes(:comments).where(:comments => {:body => 'hey'}).debug_sql
 => SELECT "articles"."id" AS t0_r0, "articles"."title" AS t0_r1,
           "articles"."body" AS t0_r2, "articles"."created_at" AS t0_r3,
           "articles"."updated_at" AS t0_r4, "articles"."lookup_id" AS t0_r5,
           "comments"."id" AS t1_r0, "comments"."article_id" AS t1_r1,
           "comments"."body" AS t1_r2, "comments"."created_at" AS t1_r3,
           "comments"."updated_at" AS t1_r4
    FROM   "articles" LEFT OUTER JOIN "comments"
           ON "comments"."article_id" = "articles"."id"
    WHERE  ("comments"."body" = 'hey')
# The (ugly) truth!


强大的Rails查询、搜索插件:SearchLogic

这个似乎更好
this is a tutorial
search logic不支持rails3
https://github.com/railsdog/searchlogic.git
上面这个好像是别人修改的版本,
问题
insalll
gem 'rd_searchlogic', :require => 'searchlogic', :git => 'git://github.com/railsdog/searchlogic.git'
posted on 2011-01-27 10:32  lexus 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/lexus/archive/2011/01/27/1945994.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值