提交 6bd25738 编写于 作者: S Sean Griffin

Add docs and changelog entry for 73aab036 [ci skip]

上级 50914b91
......@@ -11,6 +11,11 @@
*Ryuta Kamizono*
* Allow proc defaults to be passed to the attributes API. See documentation
for examples.
*Sean Griffin, Kir Shatrov*
* SQLite: `:collation` support for string and text columns.
Example:
......
......@@ -82,6 +82,14 @@ module ClassMethods
#
# StoreListing.new.my_string # => "new default"
#
# class Product < ActiveRecord::Base
# attribute :my_default_proc, :datetime, default: -> { Time.now }
# end
#
# Product.new.my_default_proc # => 2015-05-30 11:04:48 -0600
# sleep 1
# Product.new.my_default_proc # => 2015-05-30 11:04:49 -0600
#
# Attributes do not need to be backed by a database column.
#
# class MyModel < ActiveRecord::Base
......@@ -204,7 +212,8 @@ def attribute(name, cast_type, **options)
#
# +default+ The default value to use when no value is provided. If this option
# is not passed, the previous default value (if any) will be used.
# Otherwise, the default will be +nil+.
# Otherwise, the default will be +nil+. A proc can also be passed, and
# will be called once each time a new value is needed.
#
# +user_provided_default+ Whether the default value should be cast using
# +cast+ or +deserialize+.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册