4
votes

In my view I have:

<%= f.date_select :start %>

and I get the error message: can't convert Symbol into String

I know that it's related to it.date.order rule, but I see that rails-i18n include it: https://github.com/svenfuchs/rails-i18n/blob/master/rails/locale/it.yml#L51

what's wrong here?

full back trace: https://gist.github.com/4007557

EDIT: running I18n.t 'date.order' in the console give me => [:day, :month, :year]. That it's correct... so why date_select doesn't works?

issue on GitHub repo: https://github.com/svenfuchs/rails-i18n/issues/273

5

5 Answers

4
votes

I had a similar if not the same issue in the past. At the time I fixed it by using the following:

date:
  order: [ !ruby/symbol day, !ruby/symbol month, !ruby/symbol year ]
1
votes

As far as I understand the rails docs about date_select it wants to have a string.

If :start is the name of your I18n, you should do <%= f.date_select t(:start) %> as far as I remember.

1
votes

You don't have to touch you form: it's a translation problem. You should add in your it.yml file the lines you will find here: https://github.com/svenfuchs/rails-i18n/blob/master/rails/locale.

1
votes

If like in my case you are only working with years and don't want to add translations for every language with i18n just for a year selection, you can add :locale => 'en' just for that date like this:

<%= f.date_select :start, :start_year => 1940, :end_year => Date.today.year, :discard_day => true, :discard_month => true, :locale => 'en' %>
1
votes

This is a translation problem: you have to add :order rule to your it.yml file or use this line in form.

<%= f.date_select(:start, :order => [:day, :month, :year]) %>