aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorGuillermo Iguaran <guilleiguaran@gmail.com>2016-08-30 22:47:37 -0500
committerGitHub <noreply@github.com>2016-08-30 22:47:37 -0500
commit0ca595ea6e3a9523b7902b05305437054de67e43 (patch)
treeaf839cfbcb4b0e721428ce2a3d4087e62e2f237a /activerecord
parentb7ec47aa8fa0ba82b092e0965771974a14045d92 (diff)
parent547698e8524bac42d4d9011c57a120ac8b5a5fc0 (diff)
downloadrails-0ca595ea6e3a9523b7902b05305437054de67e43.tar.gz
rails-0ca595ea6e3a9523b7902b05305437054de67e43.tar.bz2
rails-0ca595ea6e3a9523b7902b05305437054de67e43.zip
Merge pull request #26327 from mechanicles/remove-duplication
Refactor remove duplication.
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/persistence.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/persistence.rb b/activerecord/lib/active_record/persistence.rb
index dc4af4f390..a6615f3774 100644
--- a/activerecord/lib/active_record/persistence.rb
+++ b/activerecord/lib/active_record/persistence.rb
@@ -178,7 +178,7 @@ module ActiveRecord
# 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 @@ module ActiveRecord
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 @@ module ActiveRecord
def belongs_to_touch_method
:touch
end
+
+ def _raise_readonly_record_error
+ raise ReadOnlyRecord, "#{self.class} is marked as readonly"
+ end
end
end