You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rails has a built-in way to customize polymorphic_type, there's a good read about it here. In a nutshell, a namespaced model such as User::Model can be stored in database using polymorphic_type user, decoupling namespacing (architecture) from database.
PaperTrail heavily relies on polymorphism and by default breaks when customizing. Specifically: In the example from above version.reify throws an error: wrong constant name user.
Problem
Rails has a built-in way to customize polymorphic_type, there's a good read about it here. In a nutshell, a namespaced model such as
User::Model
can be stored in database using polymorphic_typeuser
, decoupling namespacing (architecture) from database.PaperTrail heavily relies on polymorphism and by default breaks when customizing. Specifically: In the example from above
version.reify
throws an error:wrong constant name user
.Solution
Looking into PaperTrail's code we found that
reifier.rb
simply constantizes item_type.This line can be improved by changing it to:
clazz = version.class.polymorphic_class_for(version.item_type)
Alternatives
We currently patched this line in our own code, works.
The text was updated successfully, but these errors were encountered: