-
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
Attribute's default_value can be modified #69
Comments
That is because attribute configuration is stored at the class level. Also, freeze the default value that way this doesn't happen. |
You aren't really using the default value as it is intended (or at least implemented); default value is what to read if the attribute is not present -- you are treating it more like Hash.of_hashes "default value" mechanism (spawning an empty hash when nothing is present). |
Can you give me an example of when and how default_value should be used? I've read the description in the code # @option opts [Object] :default_value Optional attribute used to
# define a "default value" to be used if the attribute's value on an
# item is nil or not set at persistence time. But that still sounds to me like I could use this option to specify that I want an attribute initialized to something. If you're interested, I've opened a pull request that prevents the default value from getting modified: #70 |
The default value is not like MySQL default that adds the value to the record if it is not set -- this is a read-only default value.
|
If we have to freeze the value, it's a bug. Reviewing the PR's suitability as a bug fix. |
Fixed by #71 |
Released this update in version |
It's possible to modify an attribute's default_value and have those modifications carry over to new instances of the model.
Example:
The text was updated successfully, but these errors were encountered: