Version refactored

This commit is contained in:
Priit Tark 2015-01-30 23:25:46 +02:00
parent c1949e7069
commit 3e2be53853
48 changed files with 379 additions and 147 deletions

View file

@ -0,0 +1,12 @@
module VersionSession
extend ActiveSupport::Concern
included do
before_save :add_session
def add_session
self.session = PaperSession.session
true
end
end
end

View file

@ -5,6 +5,7 @@ module Versions
included do
has_paper_trail class_name: "#{model_name}Version"
# add creator and updator
before_create :add_creator
before_create :add_updator
before_update :add_updator
@ -18,5 +19,14 @@ module Versions
self.updator_str = ::PaperTrail.whodunnit
true
end
# callbacks
def touch_domain_version
domain.try(:touch_with_version)
end
def touch_domains_version
domains.each(&:touch_with_version)
end
end
end