Rails-i18n date_select error

In my opinion, I have:

<%= f.date_select :start %>

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

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

what's wrong here?

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

EDIT: run I18n.t 'date.order' in the console, give me => [:day, :month, :year] I18n.t 'date.order' => [:day, :month, :year] . What is it right ... so why date_select not working?

GitHub repository question: https://github.com/svenfuchs/rails-i18n/issues/273

+4
source share
5 answers

I had a similar, if not the same problem in the past. At that time, I fixed it using the following:

 date: order: [ !ruby/symbol day, !ruby/symbol month, !ruby/symbol year ] 
+3
source

As far as I understand the docs rails 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
source

You do not need to touch your form: this is a translation problem. You should add the lines you find here to your it.yml file: https://github.com/svenfuchs/rails-i18n/blob/master/rails/locale .

+1
source

If in my case you work only over the years and do not want to add translations for each language with i18n just for choosing a year, you can add : locale => 'en' only for this date:

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

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

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

Source: https://habr.com/ru/post/1443947/


All Articles