Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Prefix numbers with a simbol.

branch: master

NumberPrefix - Prefix numbers with a symbol

This is a ActionView::Helpers::NumberHelper module extension that implements a prefix feature. With this library you can easily format numbers prefixed with a symbol (e.g. +38.13, $+/-12.13, -14.12).

Installation (Rails 3 ready)

Add this line to your Gemfile

gem 'number_prefix'


# Options
:prefix => boolean|string
:prefix_match => :positive|:negative|:any

# Test it
number_to_currency(-1938, :prefix => true)
number_to_percentage(234.4, :prefix => '+/-')
number_with_delimiter(-45, :prefix => '@', :prefix_match => :any)
number_with_precision(-57.3, :prefix => true, :prefix_match => :negative)
number_with_precision(0, :prefix => '!', :prefix_match => :any)

Note that you can use all built-in options as well

Would you like to use these methods inside your model or controller? Add this to your class:

include ActionView::Helpers::NumberHelper
Something went wrong with that request. Please try again.