Skip to content
  • Andrew White's avatar
    46492949
    Improve the derivation of HABTM assocation join table names · 46492949
    Andrew White authored
    Improve the derivation of HABTM join table name to take account of nesting.
    It now takes the table names of the two models, sorts them lexically and
    then joins them, stripping any common prefix from the second table name.
    
    Some examples:
    
      Top level models
      (Category <=> Product)
      Old: categories_products
      New: categories_products
    
      Top level models with a global table_name_prefix
      (Category <=> Product)
      Old: site_categories_products
      New: site_categories_products
    
      Nested models in a module without a table_name_prefix method
      (Admin::Category <=> Admin::Product)
      Old: categories_products
      New: categories_products
    
      Nested models in a module with a table_name_prefix method
      (Admin::Category <=> Admin::Product)
      Old: categories_products
      New: admin_categories_products
    
      Nested models in a parent model
      (Catalog::Category <=> Catalog::Product)
      Old: categories_products
      New: catalog_categories_products
    
      Nested models in diffe...
    46492949
    Improve the derivation of HABTM assocation join table names
    Andrew White authored
    Improve the derivation of HABTM join table name to take account of nesting.
    It now takes the table names of the two models, sorts them lexically and
    then joins them, stripping any common prefix from the second table name.
    
    Some examples:
    
      Top level models
      (Category <=> Product)
      Old: categories_products
      New: categories_products
    
      Top level models with a global table_name_prefix
      (Category <=> Product)
      Old: site_categories_products
      New: site_categories_products
    
      Nested models in a module without a table_name_prefix method
      (Admin::Category <=> Admin::Product)
      Old: categories_products
      New: categories_products
    
      Nested models in a module with a table_name_prefix method
      (Admin::Category <=> Admin::Product)
      Old: categories_products
      New: admin_categories_products
    
      Nested models in a parent model
      (Catalog::Category <=> Catalog::Product)
      Old: categories_products
      New: catalog_categories_products
    
      Nested models in diffe...
Loading