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