Sha256: aac78c94b3ca2cd5bf325d2e9c5f10e00d2b6740439047d9b4e0b2662b0766c2

Contents?: true

Size: 1.18 KB

Versions: 3

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true

require "rails/generators/base"
require "rails/generators/migration"

module ValidationErrors
  module Generators
    class InstallGenerator < Rails::Generators::Base
      include Rails::Generators::Migration

      source_root File.expand_path("../../templates", __FILE__)

      # Implement the required interface for Rails::Generators::Migration.
      def self.next_migration_number(dirname)
        next_migration_number = current_migration_number(dirname) + 1
        ActiveRecord::Migration.next_migration_number(next_migration_number)
      end

      desc "Copy migrations to your application."
      def copy_migrations
        migration_template "create_validation_errors_table.rb", "db/migrate/create_validation_errors_table.rb"
        if defined?(Scenic)
          migration_template "create_flat_validation_errors.rb", "db/migrate/create_flat_validation_errors.rb"
          copy_file "flat_validation_errors_v01.sql", "db/views/flat_validation_errors_v01.sql"
        else
          puts "Scenic is not installed so we will skip the creation of the flat_validation_errors view.\nCheck the README for more information."
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
validation_errors-0.3.0 lib/generators/validation_errors/install_generator.rb
validation_errors-0.2.0 lib/generators/validation_errors/install_generator.rb
validation_errors-0.1.0 lib/generators/validation_errors/install_generator.rb