[英]Getting a undefined method `validates_presence_of' for for a custom attr_accessor
I think the trouble is coming from the fact this is a custom Model. 我认为麻烦来自于这是一个自定义模型。
Error: 错误:
undefined method `validates_presence_of' for Calculation:Class
My Model: 我的模特:
class Calculation
extend ActiveModel::Naming
include ActiveModel::Conversion
def persisted?
false
end
attr_accessor :name, :docket_num, :payments, :our_file_num,
:date_awarded, :date_paid, :amount_paid, :judgement_balance,
:results, :total_interest, :per_diem, :lda
validates_presence_of :date_awarded, :docket_num, :judgement_balance
Possibly there is something I need to include or extend to get Rails validations? 可能需要添加或扩展某些内容才能获得Rails验证吗? The project is within a rails project, but I constructed the model by hand.
该项目在Rails项目中,但是我是手动构建模型的。
Any ideas? 有任何想法吗?
try including ActiveModel::Validations
. 尝试包括
ActiveModel::Validations
。
For more info checkout the documentation on it 有关更多信息,请查看其文档
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.