srboisvert
srboisvert

Reputation: 12739

Using Rails' ActionView Helpers outside of Rails

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

Upvotes: 3

Views: 932

Answers (4)

Andrew Grimm
Andrew Grimm

Reputation: 81470

You may want to try alchemist, a ruby library for converting between lots of different units. I haven't used it myself, I've only heard about it on rubyinside.

Upvotes: 1

edebill
edebill

Reputation: 7715

You can try bringing in enough of the various Rails gems to support it (starting with ActionPack and continuing with ActiveSupport), but you're definitely going to have to bring in quite a lot - it eventually needs to have a locale system initialized with locale files for translation.

dvyjones suggestion will be much quicker if you don't need that localization.

Upvotes: 2

sarahhodne
sarahhodne

Reputation: 10106

I think this method should work. I haven't tested it though, and it doesn't accept any options other than the number.

Upvotes: 2

Azeem.Butt
Azeem.Butt

Reputation: 5861

Decide whether or not you care about all the internationalization support the method implements and then copy and paste the rest.

Upvotes: 0

Related Questions