Skip to content

A platform for community discussion. Free, open, simple.

FIX: Linking to a category via hashtag had a broken URL.

Robin Ward726d97b29deb
diff --git a/app/models/category.rb b/app/models/category.rb
index 83a842f1892..00f4e1803b7 100644
--- a/app/models/category.rb
+++ b/app/models/category.rb
@@ -692,7 +692,7 @@ class Category < ActiveRecord::Base
end
def url_with_id
- self.parent_category ? "#{url}/#{self.id}" : "#{Discourse.base_uri}/c/#{self.id}-#{self.slug}"
+ self.parent_category ? "#{url}/#{self.id}" : "#{Discourse.base_uri}/c/#{self.slug}/#{self.id}"
end
# If the name changes, try and update the category definition topic too if it's
diff --git a/spec/models/category_spec.rb b/spec/models/category_spec.rb
index fa9cf430104..300fc5561e8 100644
--- a/spec/models/category_spec.rb
+++ b/spec/models/category_spec.rb
@@ -686,7 +686,7 @@ describe Category do
fab!(:category) { Fabricate(:category_with_definition, name: 'cats') }
it "includes the id in the URL" do
- expect(category.url_with_id).to eq("/c/#{category.id}-cats")
+ expect(category.url_with_id).to eq("/c/cats/#{category.id}")
end
context "child category" do