instance method remove_reference

Ruby on Rails 4.0.13

Since v4.0.13

Available in: v4.0.13 v4.1.16 v4.2.9 v5.2.8.1 v6.0.6 v6.1.7.10 v7.0.10 v7.1.6 v7.2.3 v8.0.4 v8.1.2

Signature

remove_reference(table_name, ref_name, options = {})

Removes the reference(s). Also removes a type column if one exists. remove_reference, remove_references and remove_belongs_to are acceptable.

Remove the reference
remove_reference(:products, :user, index: true)
Remove polymorphic reference
remove_reference(:products, :supplier, polymorphic: true)

Parameters

table_name req
ref_name req
options opt = {}
Source
# File activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb, line 624
      def remove_reference(table_name, ref_name, options = {})
        remove_column(table_name, "#{ref_name}_id")
        remove_column(table_name, "#{ref_name}_type") if options[:polymorphic]
      end

Defined in activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb line 624 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveRecord::ConnectionAdapters::SchemaStatements

Type at least 2 characters to search.

↑↓ navigate · open · esc close