Sha256: b96df6599194d974f9ad8d9c0c86aa58fc8645f745821ab6b42c31dd49f22196

Contents?: true

Size: 848 Bytes

Versions: 3

Compression:

Stored size: 848 Bytes

Contents

# frozen_string_literal: true

require 'rails/generators/migration'

module SeoOptimizer
  class ErrorsPagesGenerator < Rails::Generators::Base
    source_root File.expand_path('templates', __dir__)
    desc 'Generates errors pages'

    def create_controller_files
      route %(get '/500' => 'errors#internal_server_error'\nget '/404' => 'errors#not_found'\n)

      inject_into_file 'config/application.rb', :before => "  end" do
        "\n    config.exceptions_app = self.routes\n"
      end
      %x(rm -f public/404.html)
      %x(rm -f public/500.html)
      template 'errors_controller_template.erb', File.join('app/controllers', 'errors_controller.rb')
      template '404.erb', File.join('app/views/errors', 'not_found.html.erb')
      template '500.erb', File.join('app/views/errors', 'internal_server_error.html.erb')
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
seo_optimizer-0.1.2 lib/generators/seo_optimizer/errors_pages/errors_pages_generator.rb
seo_optimizer-0.1.1 lib/generators/seo_optimizer/errors_pages/errors_pages_generator.rb
seo_optimizer-0.1.0 lib/generators/seo_optimizer/errors_pages/errors_pages_generator.rb