4

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

4

5 に答える 5

4

過去に同じ問題ではないにしても、同様の問題がありました。当時、次を使用して修正しました。

date:
  order: [ !ruby/symbol day, !ruby/symbol month, !ruby/symbol year ]
于 2012-11-04T15:51:20.657 に答える
1

Railsのドキュメントを理解している限りdate_select、文字列が必要です。

:startが I18n の名前である場合<%= f.date_select t(:start) %>、私が覚えている限り、そうする必要があります。

于 2012-11-04T15:11:47.463 に答える
1

私の場合のように、年だけで作業していて、年を選択するためだけに i18n を使用してすべての言語の翻訳を追加したくない場合は、次のようにその日付だけに:locale => 'en'を追加できます。

<%= f.date_select :start, :start_year => 1940, :end_year => Date.today.year, :discard_day => true, :discard_month => true, :locale => 'en' %>
于 2013-09-30T19:04:08.067 に答える
1

フォームに手を加える必要はありません。これは翻訳の問題です。https://github.com/svenfuchs/rails-i18n/blob/master/rails/localeにある行を it.yml ファイルに追加する必要があります。

于 2013-03-19T10:06:04.420 に答える