好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

rails 3 search plugin

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! 

https://github.com/railsdog/searchlogic.git

上面这个好像是别人修改的版本,

https://github.com/railsdog/searchlogic

问题

http://stackoverflow.com/questions/4023087/could-not-find-gem-error-when-specifying-a-forked-version-of-a-gem-from-github

insalll

  gem   'rd_searchlogic'  ,     :  require     =>     'searchlogic'  ,     :  git   =>     'git://github.com/railsdog/searchlogic.git'  

http://stackoverflow.com/questions/4310120/rails-3-meta-search-usage

查看更多关于rails 3 search plugin的详细内容...

  阅读:36次

上一篇: nginx+wordpress配置教程

下一篇:手shi目录