aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/enum.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/enum.rb b/activerecord/lib/active_record/enum.rb
index 8eaea6c055..442fb3fdc9 100644
--- a/activerecord/lib/active_record/enum.rb
+++ b/activerecord/lib/active_record/enum.rb
@@ -36,7 +36,6 @@ module ActiveRecord
# needs:
#
# Conversation.where(status: [:active, :archived])
- # Conversation.where("status <> ?", :active)
#
# You can set the default value from the database declaration, like:
#
@@ -70,6 +69,13 @@ module ActiveRecord
# Conversation.statuses[:active] # => 0
# Conversation.statuses["archived"] # => 1
#
+ # Use that class method when you need to know the ordinal value of an enum. For
+ # example, you can use that when manually building a SQL string inside a `where`
+ # condition:
+ #
+ # Conversation.where("status <> ?", Conversation.statuses[:archived])
+ #
+
module Enum
def self.extended(base) # :nodoc:
base.class_attribute(:defined_enums)