Skip to content

jaredonline/acts_as_percentage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Installing

gem "acts_as_percentage"

Requirements

Rails 3.1.x

Usage

Allows you to store percent values as an integer.

class ProgressBar < ActiveRecord::Base
    percentage :completed
end

This assumes there is a column in the database named completed_basis_point (Integer). It creates several helper methods for you:

pb = ProgressBar.create(:completed => 59.87) # => <ProgressBar: @completed_basis_point=5987>
pb.completed # => 59.87
pb.completed_ratio # => 0.5987
pb.completed_basis_point # => 5987

Raises ArgumentError if the column specified is not present

About

Lets you store percents as an Integer

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages