我有类 filter_report.rb
class FilterReport
include ActiveModel::Validations
attr_accessor :company_id
validates :company_id, presence: true
def initialize(options = {})
options.each {
|k,v|
self.send( "#{k.to_s}=".intern, v)
}
end
如何调用 FilterReport 类来显示我的验证
我要秀
report = FilterReport.new
report.company_id = ""
report.valid? => false
report.save => undefined save
我想知道验证存在的消息。
“公司不能空白”