Sha256: 295479d07848a7fe5319b6bafb1e770311f32a3a7b43e154fd1aa4e119d1c754

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

module SolidErrors
  #
  # Rails generator used for setting up SolidErrors in a Rails application.
  # Run it with +bin/rails g solid_errors:install+ in your console.
  #
  class InstallGenerator < Rails::Generators::Base
    source_root File.expand_path("templates", __dir__)

    def add_solid_errors_db_schema
      template "db/errors_schema.rb"
    end

    def configure_solid_errors
      insert_into_file Pathname(destination_root).join("config/environments/production.rb"), after: /^([ \t]*).*?(?=\nend)$/ do
        [
          "",
          '\1# Configure Solid Errors',
          '\1config.solid_errors.connects_to = { database: { writing: :errors } }',
          '\1config.solid_errors.send_emails = true',
          '\1config.solid_errors.email_from = ""',
          '\1config.solid_errors.email_to = ""',
          '\1config.solid_errors.username = Rails.application.credentials.dig(:solid_errors, :username)',
          '\1config.solid_errors.password = Rails.application.credentials.dig(:solid_errors, :password)'
        ].join("\n")
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
solid_errors-0.6.1 lib/generators/solid_errors/install/install_generator.rb