Class: SimpleErrorsGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/simple_errors/simple_errors_generator.rb

Instance Method Summary collapse

Instance Method Details

#copy_error_pagesObject



8
9
10
11
12
# File 'lib/generators/simple_errors/simple_errors_generator.rb', line 8

def copy_error_pages
  %w(404.html.erb 500.html.erb).each do |file|
    copy_file file, "app/views/errors/#{file}"
  end
end

#copy_layoutObject



4
5
6
# File 'lib/generators/simple_errors/simple_errors_generator.rb', line 4

def copy_layout
  copy_file "error.html.erb", "app/views/layouts/error.html.erb"
end

#include_simple_errorsObject



14
15
16
17
18
19
# File 'lib/generators/simple_errors/simple_errors_generator.rb', line 14

def include_simple_errors
  inject_into_file 'app/controllers/application_controller.rb', after: "class ApplicationController < ActionController::Base\n" do <<-RUBY
    include SimpleErrors::Rescue
  RUBY
  end
end

#remove_default_filesObject



21
22
23
24
# File 'lib/generators/simple_errors/simple_errors_generator.rb', line 21

def remove_default_files
  remove_file 'public/404.html'
  remove_file 'public/500.html'
end