class User
include ActiveModel::Validations
validates_presense_of :first_name
validates_length_of :last_name, :in => 3..20, :too_long => "pick a shorter last name", :too_short => "pick a longer last name"
attr_accessor :first_name, :last_name
end
你好吗
答案 0 :(得分:1)
你正在使用没有数据库的模型,对吧?您必须使用ActiveModel的翻译类扩展您的类,如下所示:
class User
[...]
extend ActiveModel::Translation
[...]