Skip to content

Instantly share code, notes, and snippets.

@chrisfinne
Created July 22, 2011 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisfinne/1099504 to your computer and use it in GitHub Desktop.
Save chrisfinne/1099504 to your computer and use it in GitHub Desktop.
Ruby/Rails - Initialize BigDecimal with commas in the String
class BigDecimal
class << self
def new_with_commas(*args)
if args.first.is_a?(String) && args.first=~/,/
args.first.gsub!(',','')
end
new_without_commas(*args)
end
alias_method_chain :new, :commas
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment