Browse Source

verify Fixed rails' db test

Mike Smith 11 years ago
parent
commit
eb0c78e6a5
1 changed files with 9 additions and 4 deletions
  1. 9 4
      rails/app/controllers/hello_world_controller.rb

+ 9 - 4
rails/app/controllers/hello_world_controller.rb

@@ -7,11 +7,16 @@ class HelloWorldController < ApplicationController
   def db
   def db
     queries = (params[:queries] || 1).to_i
     queries = (params[:queries] || 1).to_i
 
 
-    results = (1..queries).map do
-      # get a random row from the database, which we know has 10000
-      # rows with ids 1 - 10000
-      World.find(Random.rand(10000) + 1)
+    if queries > 1
+      results = (1..queries).map do
+        # get a random row from the database, which we know has 10000
+        # rows with ids 1 - 10000
+        World.find(Random.rand(10000) + 1)
+      end
+    else
+      results = World.find(Random.rand(10000) + 1)
     end
     end
+
     render :json => results
     render :json => results
   end
   end