Skip to content

Commit

Permalink
Added documentation for _default option added to ActiveRecord::Enum […
Browse files Browse the repository at this point in the history
…ci skip]
  • Loading branch information
abhaynikam committed Jul 21, 2020
1 parent b949e69 commit f17c1b7
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions activerecord/lib/active_record/enum.rb
Expand Up @@ -47,13 +47,14 @@ module ActiveRecord
# enum status: [ :active, :archived ], _scopes: false
# 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|
# t.column :status, :integer, default: 0
# class Conversation < ActiveRecord::Base
# enum status: [ :active, :archived ], _default: "active"
# 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
# database integer with a hash:
Expand Down

0 comments on commit f17c1b7

Please sign in to comment.