Sha256: 7c61ce819e05f0c97c7e7cf6532c4e95b3b34334b1b65852c80fb9cd541e7eb0

Contents?: true

Size: 915 Bytes

Versions: 1

Compression:

Stored size: 915 Bytes

Contents

module PolymorphicConstraints
  class Railtie < Rails::Railtie
    initializer 'polymorphic_constraints.load_migration' do
      ActiveSupport.on_load :active_record do
        class ActiveRecord::ReferenceViolation < ActiveRecord::ActiveRecordError
        end

        ActiveRecord::ConnectionAdapters.module_eval do
          include PolymorphicConstraints::ConnectionAdapters::SchemaStatements
        end

        if defined?(ActiveRecord::Migration::CommandRecorder)
          ActiveRecord::Migration::CommandRecorder.class_eval do
            include PolymorphicConstraints::Migration::CommandRecorder
          end
        end

        PolymorphicConstraints::Adapter.load!
      end

      ActiveSupport.on_load :action_controller do
        require 'polymorphic_constraints/utils/polymorphic_error_handler'
        include PolymorphicConstraints::Utils::PolymorphicErrorHandler
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
polymorphic_constraints-1.0.0 lib/polymorphic_constraints/railtie.rb