Created
October 26, 2009 09:03
-
-
Save henrik/3d99d172175ee3bc64a1 to your computer and use it in GitHub Desktop.
Make Active Record not cut off at the first space when assigning numbers.
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
# Foo.some_number = "123 456" should set 123456, not 123. | |
class ActiveRecord::Base | |
def convert_number_column_value_with_space_removal(value) | |
convert_number_column_value_without_space_removal(value.is_a?(String) ? value.gsub(/\s/, '') : value) | |
end | |
alias_method_chain :convert_number_column_value, :space_removal | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment