Source

I18nFloat /

Filename Size Date modified Message
lib
test
35 B
225 B
19 B
562 B
2.0 KB
880 B
1.0 KB
1.7 KB
703 B

I18nFloat

Description

Ruby gem to use with Rails. I18nFloat allows your users to use format number like "1 200,84" in forms. ActiveRecord Float attributes don't care anymore if you like commas or dots!

Features:

  • comma for decimals
  • whitespace as separator
  • standard format still usable
  • only a gem in your Gemfile and you're good to go

Installation

gem install I18nFloat

Usage

Let's say you've got a Marathon model with a Float columns named duration:

Marathon.new(:duration => "9300303.92")
# => #<Marathon id: nil, duration: 9300303.92, created_at: nil, updated_at: nil>
Marathon.new(:duration => "9300303,92")
# => #<Marathon id: nil, duration: 9300303.92, created_at: nil, updated_at: nil>
Marathon.new(:duration => "9 300 303,92")
# => #<Marathon id: nil, duration: 9300303.92, created_at: nil, updated_at: nil>

Other

If you want to contribute you should take a look at:

Problems, comments, and suggestions are welcome on the ticket system.

Copyright (c) 2011 Nicolas Cavigneaux, released under the MIT license.