mirror of https://github.com/rails/rails
Add docs and changelog entry for 73aab03
[ci skip]
This commit is contained in:
parent
50914b918e
commit
6bd2573869
|
@ -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 ActiveRecord
|
|||
#
|
||||
# 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 @@ module ActiveRecord
|
|||
#
|
||||
# +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+.
|
||||
|
|
Loading…
Reference in New Issue