【发布时间】:2017-04-26 23:11:39
【问题描述】:
我正在尝试验证我的应用程序中文本区域的字数。 我已经尝试关注this SO question,但我无法让我的工作。
我的验证:
validates :skills_response, :length => {
:minimum => 5,
:maximum => 10,
:tokenizer => lambda { |str| str.scan(/\s+|$/) },
:too_short => "must have at least %{count} words",
:too_long => "must have at most %{count} words"
}
我正在使用client side validations gem,如您所见,上述方法不起作用,因为它仍在计算字符数。
我也尝试过:tokenizer => lambda { |str| str.split },但也没有用。为什么会这样?
【问题讨论】:
标签: ruby-on-rails ruby validation client-side-validation