1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Move documentation around a bit

This commit is contained in:
David Heinemeier Hansson 2013-11-02 18:32:08 -07:00
parent 0342335473
commit fe9773414a

View file

@ -2,10 +2,7 @@ module ActiveRecord
# Declare an enum attribute where the values map to integers in the database, but can be queried by name. Example:
#
# class Conversation < ActiveRecord::Base
# enum status: [:active, :archived]
#
# # same but with explicit mapping
# enum status: {active: 0, archived: 1}
# enum status: [ :active, :archived ]
# end
#
# Conversation::STATUS # => { active: 0, archived: 1 }
@ -30,6 +27,12 @@ module ActiveRecord
# end
#
# Good practice is to let the first declared status be the default.
#
# Finally, it's also possible to explicitly map the relation between attribute and database integer:
#
# class Conversation < ActiveRecord::Base
# enum status: { active: 0, archived: 1 }
# end
module Enum
def enum(definitions)
definitions.each do |name, values|