module ActiveRecord::ReadonlyAttributes::ClassMethods

Public Instance Methods

attr_readonly(*attributes) Show source
# File activerecord/lib/active_record/readonly_attributes.rb, line 13
def attr_readonly(*attributes)
  self._attr_readonly = Set.new(attributes.map { |a| a.to_s }) + (self._attr_readonly || [])
end

Attributes listed as readonly will be used to create a new record but update operations will ignore these fields.

readonly_attributes() Show source
# File activerecord/lib/active_record/readonly_attributes.rb, line 18
def readonly_attributes
  self._attr_readonly
end

Returns an array of all the attributes that have been specified as readonly.

© 2004–2018 David Heinemeier Hansson
Licensed under the MIT License.