support where:{attr:[a,b,c]} query, check :eager param more carefully
authorTom Clegg <tom@clinicalfuture.com>
Sun, 20 Jan 2013 23:32:33 +0000 (15:32 -0800)
committerTom Clegg <tom@clinicalfuture.com>
Sun, 20 Jan 2013 23:32:33 +0000 (15:32 -0800)
app/controllers/application_controller.rb

index 2702130ee5f62be6087c9e62328ba99f89e53f82..69ba7507277a941d19e588f8c3e9be6c49bbf691 100644 (file)
@@ -41,14 +41,19 @@ class ApplicationController < ActionController::Base
         if (!value.nil? and
             attr.to_s.match(/^[a-z][_a-z0-9]+$/) and
             model_class.columns.collect(&:name).index(attr))
-          conditions[0] << " and #{attr}=?"
-          conditions << value
+          if value.is_a? Array
+            conditions[0] << " and #{attr} in (?)"
+            conditions << value
+          else
+            conditions[0] << " and #{attr}=?"
+            conditions << value
+          end
         end
       end
       model_class.where(*conditions)
     end
     @objects ||= model_class.all
-    if params[:eager]
+    if params[:eager] and params[:eager] != '0' and params[:eager] != 0 and params[:eager] != ''
       @objects.each(&:eager_load_associations)
     end
     render_list