class ActiveRecord::ConnectionAdapters::Column

Public Instance Methods

foreign_key?() click to toggle source
# File lib/tmpfk/ext/column.rb, line 2
def foreign_key?
  return false unless name.end_with?('_id')
  ActiveRecord::Base.connection.data_source_exists?(foreign_table)
end
foreign_table() click to toggle source
# File lib/tmpfk/ext/column.rb, line 7
def foreign_table
  name.humanize(capitalize: false).tableize.tableize.tr(' ', '_')
end