I'm using rails 3. In production rails nicely handles exceptions and loads my static 404.html, 500.html etc files from my public directory. However, it loads these files into my layouts/application.html.erb file. I am looking for a way to instruct rails to load these files WITHOUT using my application layout - e.g. just serve the static html file and nothing else. What is the best way to accomplish this?
thanks!
render :file => 'public/404.html', :status => :not_found, :layout => false
For an advanced approach working within the Rails framework. Update your routes
file:
get "/404", to: "errors#error_404"
get "/500", to: "errors#error_500"
Add an ErrorsController
with:
layout false
def error_404
render status: 404
end
def error_500
render status: 500
end
Then within the app/views/errors/
add your error_404.erb
and error_500.erb
files along with a snazy image and a search bar.
More info here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With