Shopify

Changing a polymorphic_type in Rails - Shopify

Feb 18, 2022
Changing a polymorphic_type in Rails - Shopify
SummaryAI, from the source post

This post details a specific technique to decouple Rails polymorphic associations from the database by replacing class names with arbitrary strings. It explains how to override the `polymorphic_name` method, adjust association scopes to handle dual `polymorphic_type` values during migration, and use a cleanup task to transition to the new string-based types. The core contribution is a simplified approach to managing namespace changes without database schema modifications.