Sha256: 85a990cdb775781beb1757b72b3b6c0634e17fc85b2a32e674ac3d417ef26b1e
Contents?: true
Size: 640 Bytes
Versions: 41
Compression:
Stored size: 640 Bytes
Contents
module ForestLiana class SchemaUtils def self.associations(active_record_class) active_record_class .reflect_on_all_associations .select {|a| !polymorphic?(a)} end def self.find_model_from_table_name(table_name) (table_name.classify.constantize rescue nil) || (table_name.capitalize.constantize rescue nil) || (table_name.sub('_', '/').camelize.singularize.constantize rescue nil) end def self.tables_names ActiveRecord::Base.connection.tables end private def self.polymorphic?(association) association.options[:polymorphic] end end end
Version data entries
41 entries across 41 versions & 1 rubygems