I have custom dynamic error pages in my Rails 3.2 app.
To ensure that the these error pages don't themselves throw errors, they use a simplified application layout that removes, among other things, dynamic user-account information (ie. like a user avatar in the header) using a simplified layout application-limited.html.erb
.
# routes.rb
get '/404', to: 'errors#page_not_found', as: :page_not_found
# errors_controller.rb
class ErrorsController < ApplicationController
def page_not_found
render status: 404, layout: 'application-limited'
end
end
When I test by visiting /404
or /500
the error page renders correctly with the limited layout. However when I test by visiting a non-existent page /foobar
I get the correct dynamic 404 error page, but strangely the normal application layout is rendered, rather than the simplified application-limited
layout.
What am I missing here?
Aucun commentaire:
Enregistrer un commentaire