mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Merge pull request #1438 from Elegios/composer_use_category_id
Make the composer and TopicCreator use category id instead of category name
This commit is contained in:
@@ -39,7 +39,14 @@ class TopicCreator
|
||||
topic_params[:archetype] = @opts[:archetype] if @opts[:archetype].present?
|
||||
topic_params[:subtype] = @opts[:subtype] if @opts[:subtype].present?
|
||||
|
||||
category = Category.where(name: @opts[:category]).first
|
||||
# Temporary fix to allow older clients to create topics.
|
||||
# When all clients are updated the category variable should
|
||||
# be set directly to the contents of the if statement.
|
||||
category = if (@opts[:category].is_a? Integer) || (@opts[:category] =~ /^\d+$/)
|
||||
Category.where(id: @opts[:category]).first
|
||||
else
|
||||
Category.where(name: @opts[:category]).first
|
||||
end
|
||||
|
||||
@guardian.ensure_can_create!(Topic,category)
|
||||
topic_params[:category_id] = category.id if category.present?
|
||||
|
||||
Reference in New Issue
Block a user