DEV: allow to have duplicate topic titles if categegory is different (#10034)

Co-authored-by: Robin Ward <robin.ward@gmail.com>

Co-authored-by: Robin Ward <robin.ward@gmail.com>
This commit is contained in:
Bernhard Suttner
2020-06-18 17:19:47 +02:00
committed by GitHub
parent ec794c7f29
commit e31471585a
6 changed files with 38 additions and 6 deletions

View File

@@ -155,7 +155,12 @@ class Topic < ActiveRecord::Base
message: :has_already_been_used,
allow_blank: true,
case_sensitive: false,
collection: Proc.new { Topic.listable_topics } }
collection: Proc.new { |t|
SiteSetting.allow_duplicate_topic_titles_category? ?
Topic.listable_topics.where("category_id = ?", t.category_id) :
Topic.listable_topics
}
}
validates :category_id,
presence: true,