From cacfb9c772b38ea4764676795f2d5152570f2b59 Mon Sep 17 00:00:00 2001 From: Hez Ronningen Date: Tue, 20 May 2014 10:48:49 -0700 Subject: [PATCH] use base_class for resolving duplicates (rails polymorphism wrecks havoc here) --- lib/has_permalink.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/has_permalink.rb b/lib/has_permalink.rb index 6c9d9a3..8b1f127 100644 --- a/lib/has_permalink.rb +++ b/lib/has_permalink.rb @@ -53,10 +53,10 @@ def to_param # Autofix duplication of permalinks def fix_duplication(permalink) if auto_fix_duplication - n = self.class.where(["permalink = ?", permalink]).count + n = self.class.base_class.where(["permalink = ?", permalink]).count if n > 0 - links = self.class.where(["permalink LIKE ?", "#{permalink}%"]).order("id") + links = self.class.base_class.where(["permalink LIKE ?", "#{permalink}%"]).order("id") number = 0