public
Description: Rails plugin to allow commas for numeric fields in ActiveRecord models
Homepage:
Clone URL: git://github.com/dramsay/comma_parser.git
comma_parser / README
100644 36 lines (23 sloc) 0.776 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
CommaParser
===========
 
This plugin allows you to accept commas from users for integer fields in
an ActiveRecord model.
 
Installation
============
 
For Rails 2.1 and above:
 
script/plugin install git://github.com/dramsay/comma_parser.git
 
 
Example
=======
 
# Table name: cities
#
# id :integer(11) not null, primary key
# name :string(50)
# population :integer(11)
 
class City < ActiveRecord::Base
  allow_commas :population
 
 
  # rest of class
end
 
Now the user can type population "1,000,000" into a form and it will still
save correctly as "1000000" instead of "1". This saves you the hassle of stripping
out commas either in JavaScript or in the controller.
 
Copyright (c) 2008 Doug Ramsay and Intridea, Inc., released under the MIT license