options_for_select with hash


I can’t find any explanation why options_for_select expects {label => value} hash, but not {value => label}.

Would it be more convenient if this behaviour is changed?


This caught me once or twice as well, until I got used to it, but I think it’s a rather complex change to do as there seems to be no way of deprecating it, it’ll likely break every single app out there that uses selects, so I’d rather keep it as is for now.

I don’t know for sure, but I’ve always assumed that the reason for this is that you sometimes want the same value repeated in different options, but almost never do you want the same label repeated (that would confuse the user), so actually the unique “key” for a group of options turns out to be the label, not the value.

I thought it was so you can just call sort on the container to sort the list for the user.