I’ve got something like this:
options_for_select({ "1 - optimal" => 1, "2 - ausreichend" => 2, "3 - verbesserungsfähig" => 3, "4 - nicht ausreichend" => 4, "5 - gar nicht" => 5})
Rails doesn’t sort these entries on output. How can I achieve the select field to be sorted numerically?
I believe in Ruby1.9, this would work as you intend (hashes preserve their insertion order), so if using 1.9 is an option then you are done.
Otherwise, you can use an array instead of a hash:
options_for_select([["1 - optimal", 1], ["2 - ausreichend", 2], ..., ["5 - gar nicht", 5]])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With