Module: DraftPunk::Model::PreviousVersionInstanceMethods
- Defined in:
- lib/activerecord/previous_version_instance_methods.rb
Instance Method Summary collapse
-
#make_current! ⇒ Activerecord Object
If the current object A is in the previous version history of a object B, this method updates B to match the approvable attributes and associations of A.
- #previous_version ⇒ Activerecord Object
Instance Method Details
#make_current! ⇒ Activerecord Object
If the current object A is in the previous version history of a object B, this method updates B to match the approvable attributes and associations of A. A copy of B is added to the previous version history.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/activerecord/previous_version_instance_methods.rb', line 11 def make_current! return unless is_previous_version? @live_version = current_approved_version @previous_version = self @live_version.draft.try(:destroy) @previous_version.update_attributes( current_approved_version_id: nil, approved_version: @live_version) @live_version.publish_draft! end |
#previous_version ⇒ Activerecord Object
23 24 25 |
# File 'lib/activerecord/previous_version_instance_methods.rb', line 23 def previous_version previous_versions.first end |