Sha256: 83bf5fc2fa156279fddfe2674a09f8d1e46fff45bea06a0b45e037512f4f1d44
Contents?: true
Size: 952 Bytes
Versions: 2
Compression:
Stored size: 952 Bytes
Contents
module ActiveRecord module ActsAsRelation module SuperclassMigration def self.included(base) base.class_eval do alias_method_chain :create_table, :as_relation_superclass end end def create_table_with_as_relation_superclass(table_name, options = {}) create_table_without_as_relation_superclass(table_name, options) do |t| if options.key? :as_relation_superclass name = options[:as_relation_superclass] if name == true name = ActiveRecord::Base.acts_as_association_name table_name end t.integer "#{name}_id" t.string "#{name}_type" t.index ["#{name}_id", "#{name}_type"], name: "#{table_name}_#{name}_index" end yield t if block_given? end end end end module ConnectionAdapters::SchemaStatements include ActsAsRelation::SuperclassMigration end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
acts_as_relation-1.1.3 | lib/active_record/acts_as_relation/superclass_migration.rb |
acts_as_relation-1.1.2 | lib/active_record/acts_as_relation/superclass_migration.rb |