Skip to content

Instantly share code, notes, and snippets.

@skojin
Created October 22, 2010 11:16
Show Gist options
  • Save skojin/640377 to your computer and use it in GitHub Desktop.
Save skojin/640377 to your computer and use it in GitHub Desktop.
simple active record/model extension to strip attributes
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