Using ActionView Rails Helpers Outside of Rails

What do I need to do to get number_to_human_size to work in a script outside the rails?

+3
ruby ruby-on-rails
source share
4 answers

You can try to collect enough different Rails gems to support it (starting with ActionPack and continuing with ActiveSupport), but you will definitely have to bring quite a lot - in the end, it must have a local system initialized with language files for translation.

The dvyjones offer will be much faster if you do not need this localization.

+2
source share

I think this method should work. I have not tested it, but it does not accept any parameters except a number.

+2
source share

You can try alchemist , a ruby ​​library to convert between many different units. I did not use it myself, I only heard about it on rubyinside.

+1
source share

Decide if you care about all the internationalization support that the method implements, and then copy and paste the rest.

0
source share

All Articles