我有一个类,我正在使用 validates 方法来检查长度,并且我想将实际长度注入错误消息中。这可能吗?
这是我当前使用验证的课程:
class Something
validates :summary, :detail, :length => {
:in => 300..500,
:too_short => "must have at least %{count} letters",
:too_long => "must have at most %{count} letters"
}
错误信息显示:
2 errors prohibited this job from being saved.
Summary must have at least 300 letters
Detail must have at least 300 letters
但我想展示:
...
Summary is only 250 letters and must have at least 300 letters
...