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
The reason I would use a non-polymorphic mixin is because I want to use it on multiple models, polymorphic and non-polymorphic alike. The only solution I've found is to duplicate my model mixin code, just swapping out models.Model with PolymorphicModel. I'd rather have only one mixin, do you know if this is possible?
The text was updated successfully, but these errors were encountered:
Only insofar that I would like features available for both non-polymorphic and polymorphic models. I strive to keep my code DRY and currently I have to define the mixin twice, once for polymorphic and non-polymorphic models. The following is an attempt to keep things DRY, but it does not work:
As you can see created_at and modified_at are not on these models so this approach doesn't work.
If PolymorphicModel could handle Model mixins, then everything would be fine. Create a single mixin (it would inhert Model), use it on Model and PolymorphicModel classes alike and enjoy DRY code.
Here are three polymorphic models, each with different mixins:
Both
Foo
andBar
have abase_manager
ofPolymorphicManager
:However, for
Baz
, itsbase_manager
is notPolymorphicManager
:The reason I would use a non-polymorphic mixin is because I want to use it on multiple models, polymorphic and non-polymorphic alike. The only solution I've found is to duplicate my model mixin code, just swapping out
models.Model
withPolymorphicModel
. I'd rather have only one mixin, do you know if this is possible?The text was updated successfully, but these errors were encountered: