Created
October 22, 2010 11:16
-
-
Save skojin/640377 to your computer and use it in GitHub Desktop.
simple active record/model extension to strip attributes
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 StripAttributes | |
def strip_attributes!(*attrs) | |
attrs.map(&:to_s) | |
before_validation do |r| | |
attrs.each do |v| | |
r[v].strip! if r[v] | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment