summaryrefslogtreecommitdiff
path: root/app/models/node.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/node.rb')
-rw-r--r--app/models/node.rb12
1 files changed, 6 insertions, 6 deletions
diff --git a/app/models/node.rb b/app/models/node.rb
index 274b2f94..02502f6c 100644
--- a/app/models/node.rb
+++ b/app/models/node.rb
@@ -112,18 +112,18 @@ class Node < ApplicationRecord
112 end 112 end
113 end 113 end
114 114
115 # Creates or updates the autosave buffer from the given attributes. 115 def ensure_autosave! current_user
116 # Autosave rows are never associated to the node via node_id -- they
117 # must never appear in self.pages / the revisions list, which is the
118 # whole reason autosave exists as a separate, unversioned layer.
119 def autosave! attributes, current_user
120 assert_locked_by! current_user 116 assert_locked_by! current_user
121
122 unless self.autosave 117 unless self.autosave
123 self.autosave = Page.create!(:editor => current_user) 118 self.autosave = Page.create!(:editor => current_user)
124 self.autosave.clone_attributes_from(self.draft || self.head) if self.draft || self.head 119 self.autosave.clone_attributes_from(self.draft || self.head) if self.draft || self.head
125 self.save! 120 self.save!
126 end 121 end
122 self.autosave
123 end
124
125 def autosave! attributes, current_user
126 ensure_autosave!(current_user)
127 self.autosave.assign_attributes(attributes) 127 self.autosave.assign_attributes(attributes)
128 self.autosave.save! 128 self.autosave.save!
129 self.autosave 129 self.autosave