ruby - Rails 4 Unitwise Gem how can I access the list of possible unit types? -


i using gem add units/amounts models. https://github.com/joshwlewis/unitwise.
followed great tutorial here http://joshwlewis.com/essays/rails-unit-measurement-persistence/.

what can not figure out how access list of units available. when creating new model, user able select unit type want save amount in.

has needed before?

the units appear defined in data/base_unit.yaml , data/derived_unit.yaml , have classes unitwise::standard::baseunit , unitwise::standard::derivedunit respectively, appear used gather data yaml files.

using classes can this:

unitwise::standard::baseunit.all.collect{|u| u.attributes['name']} 

and

unitwise::standard::derivedunit.all.collect{|u| u.attributes['name']} 

you may have these require statements first:

require 'unitwise' require 'unitwise/standard' 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -