Skip to content

Commit

Permalink
Improve enum documentation
Browse files Browse the repository at this point in the history
Add a mention about the automatic generation of scopes based on the
allowed values of the field on the enum documentation.
  • Loading branch information
robin850 committed Jan 1, 2014
1 parent 7aebcb6 commit 50060e9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion activerecord/lib/active_record/enum.rb
@@ -1,5 +1,6 @@
module ActiveRecord module ActiveRecord
# Declare an enum attribute where the values map to integers in the database, but can be queried by name. Example: # Declare an enum attribute where the values map to integers in the database,
# but can be queried by name. Example:
# #
# class Conversation < ActiveRecord::Base # class Conversation < ActiveRecord::Base
# enum status: [ :active, :archived ] # enum status: [ :active, :archived ]
Expand All @@ -23,6 +24,10 @@ module ActiveRecord
# conversation.status.nil? # => true # conversation.status.nil? # => true
# conversation.status # => nil # conversation.status # => nil
# #
# Scopes based on the allowed values of the enum field will be provided
# as well. With the above example, it will create an +active+ and +archived+
# scope.
#
# You can set the default value from the database declaration, like: # You can set the default value from the database declaration, like:
# #
# create_table :conversations do |t| # create_table :conversations do |t|
Expand Down

0 comments on commit 50060e9

Please sign in to comment.