mirror of
https://github.com/internetee/registry.git
synced 2025-08-05 17:28:18 +02:00
Version refactored
This commit is contained in:
parent
c1949e7069
commit
3e2be53853
48 changed files with 379 additions and 147 deletions
12
app/models/concerns/version_session.rb
Normal file
12
app/models/concerns/version_session.rb
Normal 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
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue