Module: ActiveRecord::ReadonlyAttributes::HasReadonlyAttributes

Defined in:
activerecord/lib/active_record/readonly_attributes.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#_write_attribute(attr_name, value) ⇒ Object



57
58
59
60
61
62
63
# File 'activerecord/lib/active_record/readonly_attributes.rb', line 57

def _write_attribute(attr_name, value)
  if !new_record? && self.class.readonly_attribute?(attr_name.to_s)
    raise ReadonlyAttributeError.new(attr_name)
  end

  super
end

#write_attribute(attr_name, value) ⇒ Object



49
50
51
52
53
54
55
# File 'activerecord/lib/active_record/readonly_attributes.rb', line 49

def write_attribute(attr_name, value)
  if !new_record? && self.class.readonly_attribute?(attr_name.to_s)
    raise ReadonlyAttributeError.new(attr_name)
  end

  super
end