def self.append_features(base)
super
debugger
puts "zOMG " + self.to_s + ", " + base.to_s
base.instance_eval do
def store_create
create_activity("Create")
end
def store_update
create_activity("Update")
end
def create_activity(action)
debugger
puts self.changes().to_s
activity = Activity.new(:actionable => self,
:action => action,
:site => self.site_id
)
self.changes().each do |c|
Change.new(:activity => activity, :attribute => c[0], :value_from => c[1][0], :value_to => c[1][1])
end
end
end
base.before_validation :store_create
base.before_create :store_create
base.before_update :store_update
end