public
Description: Rails plugin: provides a nice and easy DSL to search ActiveRecord models, including any associations thereof.
Homepage: http://rpheath.com/posts/325-rails-plugin-easysearch
Clone URL: git://github.com/rpheath/easy_search.git
added ability to add additional conditions aside from search terms only
rpheath (author)
Mon Jul 28 08:09:29 -0700 2008
commit  912cce07d7373f11c72a3935cc3782c379f0a3fd
tree    372319e308c9971e1bc9b813e385fa559dcd6ceb
parent  94b6c6199ed0af7b1f2cd7f78469f5e922ff3289
...
43
44
45
46
 
 
 
 
 
47
48
49
...
43
44
45
 
46
47
48
49
50
51
52
53
0
@@ -43,7 +43,11 @@ module RPH
0
         return [] if search_terms.blank?
0
         
0
         klass = to_model(@klass)
0
-        sanitized_sql_conditions = klass.send(:sanitize_sql_for_conditions, build_conditions_for(search_terms))
0
+        
0
+        conditions = "(#{build_conditions_for(search_terms)})"
0
+        conditions << " AND (#{options[:conditions]})" unless options[:conditions].blank?
0
+        sanitized_sql_conditions = klass.send(:sanitize_sql_for_conditions, conditions)
0
+
0
         klass.find(:all, :select => "DISTINCT #{@klass.to_s}.*", :conditions => sanitized_sql_conditions, :order => options[:order], :limit => options[:limit])
0
       end
0
       

Comments