mirror of
https://github.com/discourse/discourse.git
synced 2025-06-01 09:08:10 +08:00
FIX: Category.find_by_slug
find_by_slug should ensure that the parent actually exists when its looking for a parent.
This commit is contained in:
@ -709,7 +709,8 @@ class Category < ActiveRecord::Base
|
||||
|
||||
def self.find_by_slug(category_slug, parent_category_slug = nil)
|
||||
if parent_category_slug
|
||||
parent_category_id = self.where(slug: parent_category_slug, parent_category_id: nil).pluck(:id).first
|
||||
parent_category_id = self.where(slug: parent_category_slug, parent_category_id: nil).select(:id)
|
||||
|
||||
self.where(slug: category_slug, parent_category_id: parent_category_id).first
|
||||
else
|
||||
self.where(slug: category_slug, parent_category_id: nil).first
|
||||
|
Reference in New Issue
Block a user