Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/has_permalink.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ def to_param
# Autofix duplication of permalinks
def fix_duplication(permalink)
if auto_fix_duplication
n = self.class.where(["permalink = ?", permalink]).count
n = if id.present?
self.class.where(["permalink = ? AND id != ?", permalink, id]).count
else
self.class.where(["permalink = ?", permalink]).count
end

if n > 0
links = self.class.where(["permalink LIKE ?", "#{permalink}%"]).order("id")
Expand Down