aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/persistence.rb
diff options
context:
space:
mode:
authorFranky W <frankywahl@users.noreply.github.com>2014-11-06 09:07:29 -0800
committerFranky W <frankywahl@users.noreply.github.com>2014-11-06 19:38:58 -0800
commitd424ded6fd4b923802e9dab62b463a6f3439417f (patch)
tree88c054c1cede1b3abe8d22615f4ea2d82eee769d /activerecord/lib/active_record/persistence.rb
parent9a517b5a0b97b8872af1e66b2a5e3fd765f0d0a1 (diff)
downloadrails-d424ded6fd4b923802e9dab62b463a6f3439417f.tar.gz
rails-d424ded6fd4b923802e9dab62b463a6f3439417f.tar.bz2
rails-d424ded6fd4b923802e9dab62b463a6f3439417f.zip
Print out a meaningful error when ActiveRecord::ReadOnlyRecord is raised
Currently, there is no messages which get printed out. Convoluted system may have hooks that create other objects in which case we only fail with no messages. This commit changes this information allowing you to know which object is the one that actually raised the error.
Diffstat (limited to 'activerecord/lib/active_record/persistence.rb')
-rw-r--r--activerecord/lib/active_record/persistence.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/persistence.rb b/activerecord/lib/active_record/persistence.rb
index 9d2c9d3b9c..06c8bceb30 100644
--- a/activerecord/lib/active_record/persistence.rb
+++ b/activerecord/lib/active_record/persistence.rb
@@ -188,7 +188,7 @@ module ActiveRecord
# and <tt>destroy</tt> returns +false+. See
# ActiveRecord::Callbacks for further details.
def destroy
- raise ReadOnlyRecord if readonly?
+ raise ReadOnlyRecord, "#{self.class} is marked as readonly" if readonly?
destroy_associations
destroy_row if persisted?
@destroyed = true
@@ -519,7 +519,7 @@ module ActiveRecord
end
def create_or_update
- raise ReadOnlyRecord if readonly?
+ raise ReadOnlyRecord, "#{self.class} is marked as readonly" if readonly?
result = new_record? ? _create_record : _update_record
result != false
end