FIX: Support ember app routing to topics with only slugs

This commit is contained in:
Robin Ward
2014-09-17 11:18:41 -04:00
parent 943ad8d1d5
commit c16b8364ab
8 changed files with 54 additions and 6 deletions

View File

@ -30,6 +30,13 @@ class TopicsController < ApplicationController
skip_before_filter :check_xhr, only: [:show, :feed]
def id_for_slug
topic = Topic.find_by(slug: params[:slug].downcase)
guardian.ensure_can_see!(topic)
raise Discourse::NotFound unless topic
render json: {slug: topic.slug, topic_id: topic.id, url: topic.url}
end
def show
flash["referer"] ||= request.referer