mirror of
https://github.com/codeninjasllc/discourse.git
synced 2025-03-14 00:50:14 -04:00
proper 404 for json request 404
This commit is contained in:
parent
e91ed83586
commit
fc57578c85
1 changed files with 11 additions and 6 deletions
|
@ -66,12 +66,17 @@ class ApplicationController < ActionController::Base
|
|||
|
||||
rescue_from Discourse::NotFound do
|
||||
|
||||
f = Topic.where(deleted_at: nil, archetype: "regular")
|
||||
@latest = f.order('views desc').take(10)
|
||||
@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'
|
||||
if request.format && request.format.json?
|
||||
render status: 404, layout: false, text: "[error: 'not found']"
|
||||
else
|
||||
f = Topic.where(deleted_at: nil, archetype: "regular")
|
||||
@latest = f.order('views desc').take(10)
|
||||
@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
|
||||
|
||||
rescue_from Discourse::InvalidAccess do
|
||||
|
|
Loading…
Reference in a new issue