Browse Source

Rails: skip validation on updates (#2616)

Also, only select the fields required.
Nate Berkopec 8 years ago
parent
commit
97a34a74f4
1 changed files with 2 additions and 3 deletions
  1. 2 3
      frameworks/Ruby/rails/app/controllers/hello_world_controller.rb

+ 2 - 3
frameworks/Ruby/rails/app/controllers/hello_world_controller.rb

@@ -37,9 +37,8 @@ class HelloWorldController < ApplicationController
     worlds = (1..queries).map do
       # get a random row from the database, which we know has 10000
       # rows with ids 1 - 10000
-      world = World.find(Random.rand(10000) + 1)
-      world.randomNumber = Random.rand(10000) + 1
-      World.update(world.id, :randomNumber => world.randomNumber)
+      world = World.select(:randomNumber).find(Random.rand(10000) + 1)
+      world.update_attribute(:randomNumber => Random.rand(10000) + 1)
       world
     end