dimanche 19 mars 2017

Error when trying to making dynamic error page in rails application

I've created rails app and I've made dynamic error 404/500 page through ErrorsController:

class ErrorsController < ApplicationController
  def not_found
    render status: 404
  end

  def internal_server_error
    render status: 500
  end
end

and changing routes.rb to this:

Rails.application.routes.draw do
  resources :books
  root 'welcome#index'
  match "/404", :to => "errors#not_found", :via => :all
  match "/500", :to => "errors#internal_server_error", :via => :all
end

but whenever I run app this error comes:

Error during failsafe response: Missing template errors/200 with {:locale=>[:en], :formats=>[:css], :variants=>[], :handlers=>[:raw, :erb, :html, :builder, :ruby, :coffee, :jbuilder]}. 

and I just enable to see internal_server_error.html.erb in browser.
How can solve this?

Aucun commentaire:

Enregistrer un commentaire