Silent Touch on Active Records

My project uses a lot of nested attributes in many forms, and those model needed to be optimistically lock, using lock_version. When the child model get updated or added the parent model has to be :touch. Example would be the 'Invoice' and 'Invoice_items' scenario.

Any item added, changed or deleted form the Invoice_items the Invoice has to be :touch(updated_at changed) and lock_version changed, in order optimistically lock the record.

I have done this :-

class InvoiceItem < ActiveRecord::Base   belongs_to :invoice, :touch => true end

class Invoice < ActiveRecord::Base   has_many :invoice_items   accept_nested_attributes :invoice_items, :allow_destroy => true end

These resulted STALE error being raise.... because every invoice_item that was change, It will :touch the invoice record once cause lock_version to change.

I have try the http://github.com/UVSoft/touching_nested_attributes and it solve the problem. Should ActiveRecord add

    belongs_to :invoice, :silent_touch => true

as a new feature?

Thank You,

Sorry I forgot to tell that I am using a dynamic multi-models form. Using javascript to add and remove Invoice_Items. Then submit the Invoice, and Invoice_Items the once. These resulted STALE error being raise.... because every invoice_item that was change, It will :touch the invoice record cause lock_version to change.