Skip to content

Instantly share code, notes, and snippets.

@jmdeldin
Created August 28, 2015 19:24
Show Gist options
  • Save jmdeldin/f355529f3f7f00d9d449 to your computer and use it in GitHub Desktop.
Save jmdeldin/f355529f3f7f00d9d449 to your computer and use it in GitHub Desktop.
module StringStripper
def strip(*keys)
before_validation do
keys.each do |k|
self[k] = self[k].to_s.gsub(/[[:space:]]/, '') if self[k].present?
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment