Sha256: 0dbf4a982aafac3c07060cb9840777ec8b26b9f12dd58b9db37dc9c0904cff62

Contents?: true

Size: 839 Bytes

Versions: 15

Compression:

Stored size: 839 Bytes

Contents

module Torque
  module PostgreSQL
    module Reflection
      module AssociationReflection

        def initialize(name, scope, options, active_record)
          super

          raise ArgumentError, <<-MSG.squish if options[:array] && options[:polymorphic]
            Associations can't be connected through an array at the same time they are
            polymorphic. Please choose one of the options.
          MSG
        end

        private

          # Check if the foreign key should be pluralized
          def derive_foreign_key
            result = super
            result = ActiveSupport::Inflector.pluralize(result) \
              if collection? && connected_through_array?
            result
          end

      end

      ::ActiveRecord::Reflection::AssociationReflection.prepend(AssociationReflection)
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
torque-postgresql-1.1.8 lib/torque/postgresql/reflection/association_reflection.rb
torque-postgresql-1.1.7 lib/torque/postgresql/reflection/association_reflection.rb
torque-postgresql-2.0.3 lib/torque/postgresql/reflection/association_reflection.rb
torque-postgresql-2.0.2 lib/torque/postgresql/reflection/association_reflection.rb
torque-postgresql-1.1.6 lib/torque/postgresql/reflection/association_reflection.rb
torque-postgresql-1.1.5 lib/torque/postgresql/reflection/association_reflection.rb
torque-postgresql-2.0.1 lib/torque/postgresql/reflection/association_reflection.rb
torque-postgresql-2.0.0 lib/torque/postgresql/reflection/association_reflection.rb
torque-postgresql-1.1.4 lib/torque/postgresql/reflection/association_reflection.rb
torque-postgresql-1.1.3 lib/torque/postgresql/reflection/association_reflection.rb
torque-postgresql-1.1.2 lib/torque/postgresql/reflection/association_reflection.rb
torque-postgresql-1.1.1 lib/torque/postgresql/reflection/association_reflection.rb
torque-postgresql-1.1.0 lib/torque/postgresql/reflection/association_reflection.rb
torque-postgresql-1.0.1 lib/torque/postgresql/reflection/association_reflection.rb
torque-postgresql-1.0.0 lib/torque/postgresql/reflection/association_reflection.rb