获取未定义的方法“validates_presence_of”对于自定义 attr_accessor
我认为问题在于这是一个定制模型。
错误:
undefined method `validates_presence_of' for Calculation:Class
我的模型:
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
可能我需要包含或扩展某些内容才能获得 Rails 验证?该项目位于 Rails 项目内,但我手动构建了模型。
有什么想法吗?
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? The project is within a rails project, but I constructed the model by hand.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试包含
ActiveModel::Validations
。有关更多信息,请查看相关文档
try including
ActiveModel::Validations
.For more info checkout the documentation on it