I just released a prefixed_attributes plugin for Rails.

Rails has a handy number_to_human_size method, but in order to use it, all your quantities need to be in non-scaled units, and it‘s cumbersome to have your users typing 100 gigabyte amounts by hand. You‘d normally have a “bytes” column in your records and add virtual attributes to your models. This plugin adds those attributes for you.

Additionally, since we also add a setter method, you can, for instance, assign directly to the “gibibytes” attribute and mapping to the actual underlying “bytes” attribute is handled automatically. Thus, you can change references to the “bytes” field in your forms to “gibibytes” or whatever you want your users to actually input.

The plugin adds a prefixed_attribute method to all your classes. Use it to mark an existing attribute on your class (even a non-AR one) like this:

 prefixed_attribute :bytes, :type => :binary

 prefixed_attribute :hertz, :type => :si

To install it, switch to your project’s plugin directory and do:

git clone git://

then follow the instructions in prefixed_attributes/README.