What I put in is not what I get back


Rails date_select method takes an order argument, like this:
date_select ‘page’, ‘publish_at’, :order => [:day, :month, :year]

The items in the order array must be symbols, so this does not work:
date_select ‘page’, ‘publish_at’, :order => [‘day’, ‘month’, ‘year’]

Lets say we have this locale file:
- :year
- :month
- :day

When using i18n’s simple backend, I18n.t(‘date.order’), would return
exactly [:day, :month, :year] (an array of symbols).

However, if I change the backend to a key/value-store, such as a Hash
or Redis, the return value of I18n.t(‘date.order’) would be exactly
[‘day’, ‘month’, ‘year’] (an array of strings).

Obiously this raises a problem in Rails since the date_select (an
friends) do not accept strings in the array.

So, who to blame?

  • Should all key/value stores support Ruby symbols?
  • Should Rails accept strings in the array?
  • Should i18n try to be clever (if even possible)?