class Preseason::Recipe::CustomErrorPages

Public Instance Methods

prepare() click to toggle source
# File lib/preseason/recipe/custom_error_pages.rb, line 2
def prepare
  handle_errors_in_app
  create_errors_controller
  create_views
  remove_default_error_pages
end

Private Instance Methods

create_errors_controller() click to toggle source
# File lib/preseason/recipe/custom_error_pages.rb, line 15
def create_errors_controller
  generate 'controller errors --no-helper --no-assets'
end
create_views() click to toggle source
# File lib/preseason/recipe/custom_error_pages.rb, line 19
def create_views
  mirror_file 'app/views/errors/application_error.html.erb'
  mirror_file 'app/views/errors/not_found.html.erb'
  mirror_file 'app/views/errors/unprocessable_entity.html.erb'
end
handle_errors_in_app() click to toggle source
# File lib/preseason/recipe/custom_error_pages.rb, line 10
def handle_errors_in_app
  insert_into_file 'config/application.rb', "\n\n    config.exceptions_app = self.routes", :after => /config.active_record.whitelist_attributes = true$/
  insert 'config/routes.rb', :before => /^end$/
end
remove_default_error_pages() click to toggle source
# File lib/preseason/recipe/custom_error_pages.rb, line 25
def remove_default_error_pages
  remove_file 'public/404.html'
  remove_file 'public/422.html'
  remove_file 'public/500.html'
end