【发布时间】:2021-01-11 08:55:44
【问题描述】:
class Project
include Listable
listtable(data_attribute: :verified_at)
end
关注
module Listable
class_methods do
def listable(data_attribute: :verified_at)
raise ActiveModel::MissingAttributeError,
"Must have a verified_at attribute" unless respond_to?(:verified_at)
end
end
end
在我的
项目模型我有专栏verified_at。如果我的表中没有verified_at 列,它应该会引发错误。
但在这里它没有正确响应。总是引发错误(即使是verified_at也存在)
预期
无论我在我的模型中包含这个问题,它都应该检查 verify_at 列是否存在。如果它不存在,应该引发错误。
这对我来说没有发生,请建议我任何解决方案,提前谢谢
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-5 activesupport-concern