-
Notifications
You must be signed in to change notification settings - Fork 93
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
One of depending on another model's column #113
Comments
Hi @andresespinosapc! Currently it's not possible (see OneOf docs), but it might be a useful feature 🙂 |
I have been trying to figure out how to do this for ages, unfortunately Rails just doesn't appear to expose a good way to do it. |
I have a slightly different use case that likely requires a similar solution. Given a attribute :data, proc { store_model_class.to_type } The issue seems to be that the binding of the proc is the class instead of an instance of the class. This makes sense considering The After some digging it's not clear how this can be achieved. @DmitryTsepelev any pointers would be appreciated. Thanks. |
I have been digging into this problem as well, but the issue for me is at what point in time should you actually include the StoreModel, you could do it on the setters for that other fields, but that is not enough as setter are not always used. Ideally you would set the when the data is loaded into the instance of the object, so you can alter the objects singleton class. |
I want to use a different StoreModel depending on another column in the parent model. For example, I have a model
Order
that has an attributeprovider_name
which can beshopify
ormagento
. It has another attributeprovider_shipping_info
that is ajsonb
and I want it to have a different StoreModel depending on theprovider_name
attribute.Is it possible?
The text was updated successfully, but these errors were encountered: