Fix a case where a random topic with null slug will be rendered instead of 404

This commit is contained in:
Neil Lalonde
2013-06-07 14:17:12 -04:00
parent 668a4a3042
commit 169125e96d
3 changed files with 19 additions and 1 deletions

View File

@ -29,7 +29,7 @@ class TopicsController < ApplicationController
begin
@topic_view = TopicView.new(params[:id] || params[:topic_id], current_user, opts)
rescue Discourse::NotFound
topic = Topic.where(slug: params[:id]).first
topic = Topic.where(slug: params[:id]).first if params[:id]
raise Discourse::NotFound unless topic
return redirect_to(topic.relative_url)
end