Permalink
Browse files

Merge pull request #26327 from mechanicles/remove-duplication

Refactor remove duplication.
  • Loading branch information...
guilleiguaran committed Aug 31, 2016
2 parents b7ec47a + 547698e commit 0ca595ea6e3a9523b7902b05305437054de67e43
Showing with 6 additions and 2 deletions.
  1. +6 −2 activerecord/lib/active_record/persistence.rb
@@ -178,7 +178,7 @@ def delete
# and #destroy returns +false+.
# See ActiveRecord::Callbacks for further details.
def destroy
raise ReadOnlyRecord, "#{self.class} is marked as readonly" if readonly?
_raise_readonly_record_error if readonly?
destroy_associations
self.class.connection.add_transaction_record(self)
destroy_row if persisted?
@@ -535,7 +535,7 @@ def relation_for_destroy
end
def create_or_update(*args)
raise ReadOnlyRecord, "#{self.class} is marked as readonly" if readonly?
_raise_readonly_record_error if readonly?
result = new_record? ? _create_record : _update_record(*args)
result != false
end
@@ -577,5 +577,9 @@ def _raise_record_not_destroyed
def belongs_to_touch_method
:touch
end
def _raise_readonly_record_error
raise ReadOnlyRecord, "#{self.class} is marked as readonly"
end
end
end

0 comments on commit 0ca595e

Please sign in to comment.