mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Added documentation for _default option added to ActiveRecord::Enum [ci skip]
This commit is contained in:
parent
b949e69c5d
commit
f17c1b7796
1 changed files with 5 additions and 4 deletions
|
@ -47,13 +47,14 @@ module ActiveRecord
|
||||||
# enum status: [ :active, :archived ], _scopes: false
|
# enum status: [ :active, :archived ], _scopes: false
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
# You can set the default value from the database declaration, like:
|
# You can set the default enum value by setting +:_default+, like:
|
||||||
#
|
#
|
||||||
# create_table :conversations do |t|
|
# class Conversation < ActiveRecord::Base
|
||||||
# t.column :status, :integer, default: 0
|
# enum status: [ :active, :archived ], _default: "active"
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
# Good practice is to let the first declared status be the default.
|
# conversation = Conversation.new
|
||||||
|
# conversation.status # => "active"
|
||||||
#
|
#
|
||||||
# Finally, it's also possible to explicitly map the relation between attribute and
|
# Finally, it's also possible to explicitly map the relation between attribute and
|
||||||
# database integer with a hash:
|
# database integer with a hash:
|
||||||
|
|
Loading…
Reference in a new issue