Skip to content

Latest commit

 

History

History
25 lines (16 loc) · 609 Bytes

README.md

File metadata and controls

25 lines (16 loc) · 609 Bytes

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