mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 11:01:11 +08:00
proper 404 for json request 404
This commit is contained in:
@ -66,12 +66,17 @@ class ApplicationController < ActionController::Base
|
|||||||
|
|
||||||
rescue_from Discourse::NotFound do
|
rescue_from Discourse::NotFound do
|
||||||
|
|
||||||
f = Topic.where(deleted_at: nil, archetype: "regular")
|
if request.format && request.format.json?
|
||||||
@latest = f.order('views desc').take(10)
|
render status: 404, layout: false, text: "[error: 'not found']"
|
||||||
@recent = f.order('created_at desc').take(10)
|
else
|
||||||
@slug = params[:slug].class == String ? params[:slug] : ''
|
f = Topic.where(deleted_at: nil, archetype: "regular")
|
||||||
@slug.gsub!('-',' ')
|
@latest = f.order('views desc').take(10)
|
||||||
render status: 404, layout: 'no_js', template: '/exceptions/not_found'
|
@recent = f.order('created_at desc').take(10)
|
||||||
|
@slug = params[:slug].class == String ? params[:slug] : ''
|
||||||
|
@slug.gsub!('-',' ')
|
||||||
|
render status: 404, layout: 'no_js', template: '/exceptions/not_found'
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
rescue_from Discourse::InvalidAccess do
|
rescue_from Discourse::InvalidAccess do
|
||||||
|
Reference in New Issue
Block a user