Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Human Height Dropdown for Rails

I need a dropdown of human heights, for example 5'2, 5'3, 5'4, etc. Preferably something like 4'0 to 8'0. Is there a gem or plugin? I can't seem to find one.

like image 217
wolfbagel Avatar asked Dec 02 '25 19:12

wolfbagel


1 Answers

Presumably you'd store it in inches anyway, so you could generate your @heights to pass to options_from_collection_for_select like:

(56..112).to_a.map { |inch| { id: inch.to_s, name: (inch/12).floor.to_s+'\''+(inch%12).to_s } }

Perhaps with the inch to string conversion broken out into a helper method.

like image 123
Colin Avatar answered Dec 05 '25 10:12

Colin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!