-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Polymorphic relationships and native classes #6728
Comments
If your models only have one level of inheritance, then |
@snewcomer @yratanov we shouldn't be requiring folks to do things like override detect even if Mixins are on the way out. It's something we have supported and we should figure out a fix. Looking at this I suspect either we need to make a tweak to how we walk the chain looking for mixins in our detection logic, or there's a bug in the native class work. Given what we do in this area is a bit messy I'm going to start by assuming it is our issue and look at the submitted test to see if I can pinpoint why. cc @pzuraq for visibility |
I think a class decorator is probably going to be the right solution here long term. This isn't a requirement for Octane (though fixing this bug is), but it would probably mean moving away from For this bug, it does appear that this works with vanilla Ember: |
Is it possible to change the way polymorphic associations work? For example in Rails you don't have to declare any mixins, etc, you can put any object in it, you should just set inverse in |
I agree. There should be some way to declare polymorphic associations without mixins. Can setting an inverse just work? Or maybe a |
@Gaurav0 there is a way, you use a shared base class. The trouble with this is multi-inheritance becomes difficult-to-impossible. In the future the schema service and identifiers will allow us to not be class based at all. |
@runspired sorry for commenting on the old issue, but is there any progress or RFC on adding better polymorphic relationships than inheritance and mixins? |
@yratanov there's been a ton of progress but we need an RFC. Would you be willing to drive an effort? |
Pull request with broken test
#6727
Description
I use mixins to create polymorphic associations, but I've faced the problem with using it for native classes:
When I try to assign new value for it I get that MyModel is not polymorphable. When I don't use native class for MyModel it works as expected.
Is it a bug? What's the proper way of using polymorphic associations with native classes without using inheritance?
Versions
Run the following command and paste the output below:
The text was updated successfully, but these errors were encountered: