validates_length_of :certificateno, :within => 18..18 ,:message=>"身份证号长度须为18位数! "
验证效果不佳:字段验证的时候出现“{{attribute}} {{message}}”.
1 errors prohibited this order from being saved
There were problems with the following fields:
{{attribute}} {{message}}
解决方法:在CN里配置:
activerecord:
models:
user: "用户"
rcrm_lead: "申请表"
attributes:
user:
email: "电子邮件"
name: "真实姓名"
position: "职称"
phone: "固话"
mobile: "手机"
field: "研究领域"
address: "地址"
post: "邮编"
password: "密码"
password_confirmation: "密码确认"
rcrm_lead:
certificateno: "身份证号码"
contribution:
kind: "类型"
title: "论文题目"
title_2nd: "English Title"
abstract_2nd: "English Abstract"
short_title: "短标题"
abstract: "摘要"
field: "领域"
errors:
full_messages:
format: "%{attribute} %{message}"
messages:
blank: "不能为空"
confirmation: "与重复值不符合"
invalid: "是无效的"
taken: "已经被使用"
too_short: "太短"
not_a_number: "不是数字"
template:
header:
one: "有一个错误"
other: "有{{count}}个错误"
body: "以下错误信息"