aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorNeeraj Singh <neerajdotname@gmail.com>2010-07-18 07:54:48 -0400
committerJosé Valim <jose.valim@gmail.com>2010-07-21 14:55:57 +0200
commit992711a86bc4ddd4460f9067e49eea36b37ca94f (patch)
tree230b419c54ec4633ea033c847a7a8b81ea7a9683 /activerecord/lib
parentc96a50539121c4a722f354220c7f0e314b24804d (diff)
downloadrails-992711a86bc4ddd4460f9067e49eea36b37ca94f.tar.gz
rails-992711a86bc4ddd4460f9067e49eea36b37ca94f.tar.bz2
rails-992711a86bc4ddd4460f9067e49eea36b37ca94f.zip
update_attribute should not update readonly attributes
[#5106 state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/persistence.rb2
1 files changed, 2 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/persistence.rb b/activerecord/lib/active_record/persistence.rb
index 7ec443ccc7..e2d92c860c 100644
--- a/activerecord/lib/active_record/persistence.rb
+++ b/activerecord/lib/active_record/persistence.rb
@@ -105,6 +105,8 @@ module ActiveRecord
# Updates a single attribute and saves the record without going through the normal validation procedure
# or callbacks. This is especially useful for boolean flags on existing records.
def update_attribute(name, value)
+ raise ActiveRecordError, "#{name.to_s} is marked as readonly" if self.class.readonly_attributes.include? name.to_s
+
changes = record_update_timestamps || {}
if name