Class: ActiveRecord::ConnectionAdapters::TableDefinition
- Inherits:
-
Object
- Object
- ActiveRecord::ConnectionAdapters::TableDefinition
- Defined in:
- lib/active_record_foreign_keys.rb
Instance Method Summary collapse
Instance Method Details
#references_with_foreign_key(*args) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/active_record_foreign_keys.rb', line 6 def references_with_foreign_key(*args) = args. cols = args.dup = .delete(:foreign_key) || false references_without_foreign_key(*(args << )) unless [:polymorphic] || == false @table_statements ||= [] = {} unless .is_a?(Hash) cols.each do |col| @table_statements << @base.foreign_key_sql(@table_name, "#{col}_id", col.to_s.pluralize, "id", ) end end end |
#to_sql_with_foreign_key ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/active_record_foreign_keys.rb', line 21 def to_sql_with_foreign_key col_defs = to_sql_without_foreign_key if @table_statements.is_a?(Array) && @table_statements.size > 0 sql = col_defs + ", " + (@table_statements * ", ") else sql = col_defs end sql end |