Error saving draft on a resource that already has a draft
Closed this issue · 4 comments
As @andymcintosh pointed out in #59, there may be an issue with saving a draft on a resource that already has a draft when there is no object_changes
column in the drafts
table.
Thanks Chris, I considered making a new issue but wanted to collect a little more information. I have isolated the behavior in a simple (Dockerized) Rails app if that helps at all. I can find no discernible problems with using the '--with-changes' flag in my case, so I'm able to move forward. Just wanted to share what I learned.
@andymcintosh For sure! I'm glad you commented on the other issue because it gives me a case to play around with for that issue.
PLEASE DISREGARD THIS! My fault! Didn't restart rake after deleting the column.
For some reason
def track_object_changes_for_draft?
self.class.draft_class.column_names.include?('object_changes')
end
is always returning true, even when the column does not exist.
On a side note, should it be:
def track_object_changes_for_draft?
self.class.draft_class.object_changes_col_present?
end
Since that method in the Draft class does the same thing?
The problem is in line 400 of model.rb
if self.draft? && self.draft.changeset.key?(attr)
Changing it to:
if self.draft? && self.draft.changeset && self.draft.changeset.key?(attr)
Fixes it for me, but not sure if it breaks something else.