提交 254693a3 编写于 作者: S Sean Griffin

Document the usage of the default option to attribute

上级 009e3d0b
......@@ -63,6 +63,20 @@ module ClassMethods
# # after
# store_listing.price_in_cents # => 10
#
# A default can also be provided.
#
# create_table :store_listings, force: true do |t|
# t.string :my_string, default: "original default"
# end
#
# StoreListing.new.my_string # => "original default"
#
# class StoreListing < ActiveRecord::Base
# attribute :my_string, :string, default: "new default"
# end
#
# StoreListing.new.my_string # => "new default"
#
# Attributes do not need to be backed by a database column.
#
# class MyModel < ActiveRecord::Base
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册