Fix a case when the wrong topic is loaded because the slug starts with a number

This commit is contained in:
Neil Lalonde
2013-08-22 15:46:17 -04:00
parent f2c4b3e37f
commit 86012ac579
2 changed files with 17 additions and 2 deletions

View File

@@ -111,8 +111,8 @@ class ListController < ApplicationController
private
def set_category
category_slug = params.fetch(:category)
@category = Category.where("slug = ? or id = ?", category_slug, category_slug.to_i).includes(:featured_users).first
slug = params.fetch(:category)
@category = Category.where("slug = ?", slug).includes(:featured_users).first || Category.where("id = ?", slug.to_i).includes(:featured_users).first
end
def request_is_for_uncategorized?