aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/enum.rb6
-rw-r--r--activerecord/test/cases/enum_test.rb4
2 files changed, 7 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/enum.rb b/activerecord/lib/active_record/enum.rb
index 1afbfb1977..470e0b5d29 100644
--- a/activerecord/lib/active_record/enum.rb
+++ b/activerecord/lib/active_record/enum.rb
@@ -36,6 +36,7 @@ module ActiveRecord
# needs:
#
# Conversation.where(status: [:active, :archived])
+ # Conversation.where.not(status: :active)
#
# You can set the default value from the database declaration, like:
#
@@ -69,9 +70,8 @@ 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:
+ # Use that class method when you need to know the ordinal value of an enum.
+ # For example, you can use that when manually building SQL strings:
#
# Conversation.where("status <> ?", Conversation.statuses[:archived])
#
diff --git a/activerecord/test/cases/enum_test.rb b/activerecord/test/cases/enum_test.rb
index 025e39c02d..e70d492efd 100644
--- a/activerecord/test/cases/enum_test.rb
+++ b/activerecord/test/cases/enum_test.rb
@@ -42,6 +42,8 @@ class EnumTest < ActiveRecord::TestCase
refute_equal @book, Book.where(status: :written).first
assert_equal @book, Book.where(status: [:proposed]).first
refute_equal @book, Book.where(status: [:written]).first
+ refute_equal @book, Book.where.not(status: :proposed).first
+ assert_equal @book, Book.where.not(status: :written).first
end
test "find via where with strings" do
@@ -49,6 +51,8 @@ class EnumTest < ActiveRecord::TestCase
refute_equal @book, Book.where(status: "written").first
assert_equal @book, Book.where(status: ["proposed"]).first
refute_equal @book, Book.where(status: ["written"]).first
+ refute_equal @book, Book.where.not(status: "proposed").first
+ assert_equal @book, Book.where.not(status: "written").first
end
test "build from scope" do