提交 547698e8 编写于 作者: S Santosh Wadghule

Refactor remove duplication.

上级 3132fa6b
......@@ -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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册