fix up load_where_param
authorTom Clegg <tom@clinicalfuture.com>
Fri, 14 Jun 2013 15:39:41 +0000 (11:39 -0400)
committerTom Clegg <tom@clinicalfuture.com>
Fri, 14 Jun 2013 15:39:41 +0000 (11:39 -0400)
services/api/app/controllers/application_controller.rb

index a10ec5e52c3aca2a12173cf6579abd47d18930f4..e385dc8dad20f67d2e468eaccec51832d129f3de 100644 (file)
@@ -93,8 +93,17 @@ class ApplicationController < ActionController::Base
   protected
 
   def load_where_param
-    @where = params[:where] || {}
-    @where = Oj.load(@where) if @where.is_a?(String)
+    if params[:where].nil? or params[:where] == ""
+      @where = {}
+    elsif params[:where].is_a? Hash
+      @where = params[:where]
+    elsif params[:where].is_a? String
+      begin
+        @where = Oj.load(params[:where])
+      rescue
+        raise ArgumentError.new("Could not parse \"where\" param as an object")
+      end
+    end
   end
 
   def find_objects_for_index