我有关于验证的问题有类
/app/models/group.rb
class Group < AbstractModel
include Localized::Title
...
end
/app/models/concerns/localized/title.rb
module Localized::Title
extend ActiveSupport::Concern
include ActiveModel::Validations
include do
validates :title_ua, length: {minimum: 3, maximum: 200}, uniqueness: true
validates :title_ru, length: {minimum: 3, maximum: 200}, uniqueness: true
end
...
end
当我尝试在模型中使用验证时,它可以工作,但不用担心。请帮助我,我做错了什么?
PS AbstractModel < ActiveRecord::Base, rails 4.2, ruby 2.2.0p0