我有一个ActiveAttr模型,我想使用ActiveRecord对某些数据进行查找
class Api::V1::Salesubmit
include ActiveAttr::Model
include ActiveModel::Validations::Callbacks
attribute :secret
.
.
.
validate :validate_merchant
def validate_merchant
# Lookup merchant here
#
Merchant.where('secret = ?', self.secret).first
end
end
然而,即使我有一个定义的商家,也找不到它。还是一个
Merchant.all.size
即使存有商家,也会返回0.
有没有办法从ActiveAttr验证中通过ActiveRecord访问数据?