Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ar_strip_commas

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ar_strip_commas

  • 0.1.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

= ar_strip_commas

This gem adds two class methods to ActiveRecord::Base for automatically handling the conversion of strings with commas ("1,203") to the intended value on numeric columns.

*self.strip_commas_from(columns)

Remove commas on the specified column. e.g.

class Widget < ActiveRecord::Base
  strip_commas_from :price
end
Widget.new(:price => "1,200").price == 1200    # true

self.strip_commas_from_all_numbers

Remove commas from all numeric columns. e.g.

class Widget < ActiveRecord::Base
  strip_commas_from_all_numbers
end
widget = Widget.new(:price => "1,200", :weight => "1,872.0")
widget.price == 1200     # true
widget.weight == 1872.0  # true

= the right way?

I'm surprised I couldn't find anything built into rails for handling this. If someone knows the "right way" to handle this, send me an email and I'll replace this project with a readme describing it.

FAQs

Package last updated on 10 Feb 2011

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc