-
Notifications
You must be signed in to change notification settings - Fork 41
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
Derived Column Values #58
Comments
I think at first pass that a I'll have to think on this for a bit - I see the problem you're getting at, would like to think of a way to solve in a generalized manner. |
Yes, sort of like ActiveRecord's before_commit hook. Update poses a different problem (posting a second issue to discuss because my solution is copy pasting your code). |
Though an
This is nice because I can read back values before saving:
|
Apologies for the late response on this. We agree that this should be behavior that you define on the class. The code samples provided will already accomplish this! Though there appears to be a minor bug in the sample. If you use |
Question: is there a good way to have columns whose values are derived from other columns and to have those values be correctly populate for all interfaces? For example:
Derived from would take an array of fields and would execute the block when any referenced column is changed, passing their values to the block either separately or as a hash.
Then one would expect:
My work-around for this was along the lines of:
Which works for the simple create/save case:
But, as I just discovered, does not work for updates (because no instance is ever involved):
Would love to see a generalized way of doing this; seems pertinent for dynamically generating GSIs and having everything play nicely...
Current work around will be (though now I need a base record class rather than module so super will actually work):
The text was updated successfully, but these errors were encountered: