0
Scorecard
クラスにafter_save
コールバックがあります。ActiveRecordにハッシュを渡す#save
このコールバックでは、オブジェクトを作成して別のモデルBalanceLedger
に保存します。
がScorecard
のafter_save
に作成され、これは可能ですか?
(これは有効ではありませんが、全体で私のポイントを取得しようとしているところ)
scorecard.total = new_total
scorecard.save(message: 'This is an Admin correction')
class Scorecard < ActiveRecord::Base
after_save do
BalanceLedger.create!(total: total, message: params[:message])
end
私はこの考えが好きです。私はこれを見てみましょう。 – slindsey3000