我有一个表单(使用 simple_form),我想实现对已翻译错误消息的支持。我的所有翻译都会出现,但错误消息除外。
我的客户模型是:
class Customer < ActiveRecord::Base
attr_accessible :name, :phone, :email, :contact_method
validates_presence_of :phone, :email, :contact_method, :message => I18n.t(:required)
end
我的fr.yml
档案
fr:
name: 'Nom'
phone: 'Téléphone'
email: 'Courriel'
contact_method: 'Méthode de contact'
required: 'Requis'
我的表格如下:
= simple_form_for @customer do |f|
= f.input :name, label: t(:name)
= f.input :phone, label: t(:phone)
= f.input :email, label: t(:email)
有什么我想念的吗?