Sha256: 09c4ce245c58b0eb22506ae7ce33590ced0f269719c2c75a011df9cf3d77f0db

Contents?: true

Size: 286 Bytes

Versions: 1

Compression:

Stored size: 286 Bytes

Contents

class ActiveRecord::ConnectionAdapters::Column
  def foreign_key?
    return false unless name.end_with?('_id')
    ActiveRecord::Base.connection.data_source_exists?(foreign_table)
  end

  def foreign_table
    name.humanize(capitalize: false).tableize.tableize.tr(' ', '_')
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tmpfk-0.1.1 lib/tmpfk/ext/column.rb