class Package
include DataMapper::Resource
property :id, Serial
property :product, String, :required => true
def self.create(attributes = {})
puts 'I am in the Object method'
#do something here with value of product before creating a new row
create(attributes)
end
end
p = Package.new
p.create :product=>'myprod'
実際には、Datamapper が提供する「create」メソッドのラッパーが必要です。そのため、Package テーブルに行を作成する前に、"product" の値で何かを行うことができます。しかし、上記の実装は間違っており、循環呼び出しで失われるようです。私は得る
.......
.......
I am in the Object method
I am in the Object method
I am in the Object method
I am in the Object method
I am in the Object method
I am in the Object method
I am in the Object method
I am in the Object method
I am in the Object method
SystemStackError - stack level too deep:
私は何を間違っていますか?どうすれば目標を達成できますか