Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Improve enum documentation

Add a mention about the automatic generation of scopes based on the
allowed values of the field on the enum documentation.
  • Loading branch information...
commit 50060e969b422e6cd8f90181ac3d92f915a96f69 1 parent 7aebcb6
@robin850 robin850 authored
Showing with 6 additions and 1 deletion.
  1. +6 −1 activerecord/lib/active_record/enum.rb
View
7 activerecord/lib/active_record/enum.rb
@@ -1,5 +1,6 @@
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
# enum status: [ :active, :archived ]
@@ -23,6 +24,10 @@ module ActiveRecord
# conversation.status.nil? # => true
# 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:
#
# create_table :conversations do |t|
Please sign in to comment.
Something went wrong with that request. Please try again.