Sha256: 52921fedbf55aabe5d4c4dc2afe9b9f5d276ddc8f31b25f9bebf9734f99c4a5c
Contents?: true
Size: 656 Bytes
Versions: 1
Compression:
Stored size: 656 Bytes
Contents
module RedHillConsulting::AutomaticForeignKey::ActiveRecord module Base def self.included(base) base.extend(ClassMethods) end module ClassMethods def references(table_name, column_name, options = {}) column_name = column_name.to_s if options.has_key?(:references) references = options[:references] references = [references, :id] unless references.nil? || references.is_a?(Array) references elsif column_name == 'parent_id' [table_name, :id] elsif column_name =~ /^(.*)_id$/ [pluralized_table_name($1), :id] end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
automatic_foreign_key-1.0.0 | lib/red_hill_consulting/automatic_foreign_key/active_record/base.rb |