Nested attributes not getting tracked
adityashankert opened this issue · comments
Hi I have a scenario in that i have updated the embedded_document using nested attributes but it is not getting tracked but the changes in the outer document are getting tracked can I know how to get that working?
the following is the tracking_history initialization in the models
#invoice.rb
class Invoice
include Mongoid::Document
include Mongoid::Attributes::Dynamic
include Mongoid::Timestamps
include Mongoid::History::Trackable
embeds_many :invoice_details
accepts_nested_attributes_for :invoice_details
track_history :on => :all
end
#invoice_detail.rb
class InvoiceDetail
include Mongoid::Document
include Mongoid::Attributes::Dynamic
include Mongoid::Timestamps
include Mongoid::History::Trackable
embedded_in :invoice
track_history :on=> :all,
:scope => :invoice,
:track_create => true,
:track_destroy => true
end
I think this is a feature request, not currently supported.
thanks :)
I think that setting cascade_callbacks: true
will make it work. At least, if I understood your problem correctly.
embeds_many :invoice_details, cascade_callbacks: true
(sorry to publish this 3 months later...)