Skip to content
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

Allow fallback to default value when assigning nil #370

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

lime
Copy link

@lime lime commented Oct 14, 2016

This is a revamp of the feature proposed in #292, though named differently. I tried to avoid confusion by making the name pretty explicit, but I'm open to suggestions if you feel there are better naming options.

When configuring use_default_on_nil: true, an attribute which gets set to nil will fallback to the :default value.

The implementation is heavily based on the :nullify_blank option in #314.

Let me know what you think. :)

:use_default_on_nil makes an attribute fallback to the :default value
(if one is set) when attempting to set it to nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant