Sha256: 02db1d31f0e4ea8536f8d06a14d530a45a823b01f70588cc96880609cb61dcd3
Contents?: true
Size: 894 Bytes
Versions: 2
Compression:
Stored size: 894 Bytes
Contents
module Lolita module Configuration module Helper class << self # Return true if field name matches one of these: # * created_at, updated_at, type # * ends with _id, but there is no association that uses that field as foreign_key # * there are uploader with that name def tehnical_field?(db_field,dbi) name = db_field[:name].to_s if name.match(/^created_at|updated_at|type$/) true elsif name.match(/_id$/) # FIXME move this to dbi association proxy key_method = dbi.adapter_name == :active_record ? :association_foreign_key : :key !dbi.associations.values.detect{|assoc| assoc.send(key_method) == name} elsif dbi.klass.respond_to?(:uploaders) dbi_klass.uploaders.keys.include?(name.to_sym) end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
lolita-3.1.16 | lib/lolita/configuration/helper.rb |
lolita-3.1.15 | lib/lolita/configuration/helper.rb |