Created
November 27, 2010 10:11
-
-
Save henrik/717764 to your computer and use it in GitHub Desktop.
ActiveRecord mixin to save NULL instead of empty strings to database.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module NullifyBlankAttributes | |
def write_attribute(attr_name, value) | |
new_value = value.presence | |
super(attr_name, new_value) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment