From e2322a9087d7eb5dc78b72c6ffacfe55a50b8c9e Mon Sep 17 00:00:00 2001 From: David Jones Date: Tue, 15 May 2012 09:40:24 -0700 Subject: Make the 'Using Models in Your Migrations' example code more concise by using update_all method --- guides/source/migrations.textile | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'guides/source/migrations.textile') diff --git a/guides/source/migrations.textile b/guides/source/migrations.textile index f855072fd8..52dba76e68 100644 --- a/guides/source/migrations.textile +++ b/guides/source/migrations.textile @@ -737,9 +737,7 @@ column. class AddFlagToProduct < ActiveRecord::Migration def change add_column :products, :flag, :boolean - Product.all.each do |product| - product.update_attributes!(:flag => false) - end + Product.update_all :flag => false end end @@ -762,9 +760,7 @@ column. class AddFuzzToProduct < ActiveRecord::Migration def change add_column :products, :fuzz, :string - Product.all.each do |product| - product.update_attributes! :fuzz => 'fuzzy' - end + Product.update_all :fuzz => 'fuzzy' end end @@ -816,9 +812,7 @@ class AddFlagToProduct < ActiveRecord::Migration def change add_column :products, :flag, :boolean Product.reset_column_information - Product.all.each do |product| - product.update_attributes!(:flag => false) - end + Product.update_all :flag => false end end @@ -833,9 +827,7 @@ class AddFuzzToProduct < ActiveRecord::Migration def change add_column :products, :fuzz, :string Product.reset_column_information - Product.all.each do |product| - product.update_attributes!(:fuzz => 'fuzzy') - end + Product.update_all :fuzz => 'fuzzy' end end -- cgit v1.2.3