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.
On Dec 7, 12:53 am, tankwanghow <[email protected]> wrote: > 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 :touchthe invoice record once cause > lock_version to change. > > I have try thehttp://github.com/UVSoft/touching_nested_attributesand > it solve the problem. ShouldActiveRecordadd > > belongs_to :invoice, :silent_touch => true > > as a new feature? > > Thank You, -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

