の欠落によって引き起こされる未定義のメソッド `マップ」Iはdatetime
に:string
から4 new.html.erb
Railsではdatetime
フィールドのフォーマットを変更し、それは以下のようにエラーの原因:原因レールは:国際化翻訳
undefined method `map' for "translation missing: zh-CN.date.order":String
ビューコード上記のエラーがある:
<%= f.input :start_time, :label => t("Start Time"), required: true, :as => :datetime, :ampm => true, :minute_step => 10, :start_year => Date.today.year - 1, :end_year => Date.today.year + 1, :format => 'YYYY/MM/DD/HH/MM', :use_month_numbers => true, :include_blank => true %>
RAILS
ソースコードが吹くactionview/helpers/date_helper.rb
にある:
def translated_date_order
date_order = I18n.translate(:'date.order', :locale => @options[:locale], :default => [])
date_order = date_order.map { |element| element.to_sym } #<<<<<<===blows up
forbidden_elements = date_order - [:year, :month, :day]
if forbidden_elements.any?
raise StandardError,
"#{@options[:locale]}.date.order only accepts :year, :month and :day"
end
date_order
end
私は/config/locale/
の下にファイルzh-CN.yml
を持っていますが、それ以外の人には翻訳を提供しています。 zh-CN.yml
の
UPDATE部:この同じエラーに刺された後
zh-CN:
#maint_recordx
Mfg Batches : '订单批次一览'
New Batch : '新批次'
Update Batch : '更新批次'
Edit Batch : '更新批次'
...........
.ymlの構造を表示できますか?おそらく小さなタイプミスがあります –
ヘルパーメソッドにタイプミスがあります: ': 'date.order''。 ':'を削除すると、文字列でなければなりません。それが修正された場合は、ここでは適用されなくなるので、この質問を削除することをお勧めします。 – mmichael
'mmichael'、ヘルパーメソッドはRailsのソースコードから/ actionview /の下に直接コピーされます。またそれを取り除くことは役に立たなかった。 – user938363