DataMapper模型允许两种形式的自定义验证:特定于属性的验证和整体对象验证。例如: # Validates the `name` property with the `check_name` method;
# any errors will be under `object.errors[:name]`
validates_with_method :name, method: :che
在我的Profile类中,与n关联:fields是有问题的。如果它的存在,我运行以下命令: user = User.create
user.profiles << Profiles.new
user.save
Profile.all
下抛出异常: SystemStackError: stack level too deep
from /Users/jon/.rvm/gems/r
假设我有以下的DataMapper模式: class Payment
include DataMapper::Resource
property :id, Serial
property :amount, Decimal, precision: 8, scale: 2
end
然后我做到以下几点: p = Payment.new(:amount => 12.3