company has_many phone_numbers
company has_many contacts
company has_one status
.... and so on
I need to be able to have the plugin version each associated model
Does anyone know of a solution for this?
I haven't heard of anything like that.
But I can't imagine you can adapt ActsAsVersioned to your needs,
because it works with a different table, so associations are going to
Perhaps a more bespoke solution;
add_column :companies, :versioned_at, :datetime, :default => nil
add_column :companies, :version_of, :integer, :default => nil
Now when we "version" it, we go.
has_many :versions, :class_name => "Company", :foreign_key =>
"version_id", :order => "companies.versioned_at DESC"
belongs_to :version_of, :class_name => "Company"
versioned = Company.new(self.attributes.merge(:versioned_at =>
Time.now, :version_of => self.id)
# go through each association and clone the attribs, pointing at
self.phone_numbers.each do |phone_number|
something like that maybe?
(totally untested code)
Matthew Rudy Jacobs