about summary refs log tree commit diff
path: root/app/models
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2019-03-13 13:02:13 +0100
committerGitHub <noreply@github.com>2019-03-13 13:02:13 +0100
commit06663fcf87fe0d6bc71336e6f212b82f098066d7 (patch)
tree267ca2c141cc77c68c85d1229ace0646cce6ad29 /app/models
parentd4ef90eae39f8c00be3dd2c6785fe9ece1f055ff (diff)
Fix `tagged` param not being normalized before querying tags (#10249)
Diffstat (limited to 'app/models')
-rw-r--r--app/models/tag.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/app/models/tag.rb b/app/models/tag.rb
index 788a678bd..7db76d157 100644
--- a/app/models/tag.rb
+++ b/app/models/tag.rb
@@ -72,6 +72,14 @@ class Tag < ApplicationRecord
          .limit(limit)
          .offset(offset)
     end
+
+    def find_normalized(name)
+      find_by(name: name.mb_chars.downcase.to_s)
+    end
+
+    def find_normalized!(name)
+      find_normalized(name) || raise(ActiveRecord::RecordNotFound)
+    end
   end
 
   private