class Adminpanel::CustomErrorsGenerator

Public Instance Methods

copy_errors_controller() click to toggle source
# File lib/generators/adminpanel/custom_errors/custom_errors_generator.rb, line 9
def copy_errors_controller
  copy_file 'errors_controller.rb', 'app/controllers/errors_controller.rb'
end
copy_errors_template() click to toggle source
# File lib/generators/adminpanel/custom_errors/custom_errors_generator.rb, line 13
def copy_errors_template
  copy_file 'show.html.erb', 'app/views/errors/show.html.erb'
end
inject_error_handling_app_in_configuration() click to toggle source
# File lib/generators/adminpanel/custom_errors/custom_errors_generator.rb, line 23
def inject_error_handling_app_in_configuration
  inject_into_file 'config/application.rb', after: 'class Application < Rails::Application' do
    "\n    config.exceptions_app = -> (env) { ErrorsController.action(:show).call(env) }"
  end
end
inject_errors_into_routes() click to toggle source
# File lib/generators/adminpanel/custom_errors/custom_errors_generator.rb, line 17
def inject_errors_into_routes
  inject_into_file 'config/routes.rb', before: "\nend\n" do
    "\n  get \"(errors)/:status\", to: \"errors#show\", constraints: { status: /\d{3}/ }"
  end
end
print_messages() click to toggle source