Created
October 27, 2009 14:04
-
-
Save metaskills/219579 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 AttrStripper | |
module Stripper | |
def self.included(base) | |
base.alias_method_chain :write_attribute, :attr_stripper | |
end | |
def write_attribute_with_attr_stripper(attr, value) | |
value = value.dup.strip if value.is_a?(String) | |
write_attribute_without_attr_stripper(attr,value) | |
end | |
end | |
end | |
ActiveRecord::Base.send :include, AttrStripper::Stripper |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment