mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
minor changes in migrations guide
This commit is contained in:
parent
5adb90a14f
commit
688b0c318f
1 changed files with 4 additions and 4 deletions
|
@ -540,7 +540,7 @@ end
|
||||||
# app/model/product.rb
|
# app/model/product.rb
|
||||||
|
|
||||||
class Product < ActiveRecord::Base
|
class Product < ActiveRecord::Base
|
||||||
validates_presence_of :flag
|
validates :flag, :presence => true
|
||||||
end
|
end
|
||||||
</ruby>
|
</ruby>
|
||||||
|
|
||||||
|
@ -561,8 +561,7 @@ end
|
||||||
# app/model/product.rb
|
# app/model/product.rb
|
||||||
|
|
||||||
class Product < ActiveRecord::Base
|
class Product < ActiveRecord::Base
|
||||||
validates_presence_of :flag
|
validates :flag, :fuzz, :presence => true
|
||||||
validates_presence_of :fuzz
|
|
||||||
end
|
end
|
||||||
</ruby>
|
</ruby>
|
||||||
|
|
||||||
|
@ -594,9 +593,10 @@ If Alice had done this instead, there would have been no problem:
|
||||||
class AddFlagToProduct < ActiveRecord::Migration
|
class AddFlagToProduct < ActiveRecord::Migration
|
||||||
class Product < ActiveRecord::Base
|
class Product < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def change
|
def change
|
||||||
add_column :products, :flag, :int
|
add_column :products, :flag, :int
|
||||||
Product.reset_column_information
|
Product.reset_column_information
|
||||||
Product.all.each { |f| f.update_attributes!(:flag => false) }
|
Product.all.each { |f| f.update_attributes!(:flag => false) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue