instance method
arel_attributes_values
Ruby on Rails 3.1.12
Since v3.0.20 Last seen in v3.1.12 PrivateAvailable in: v3.0.20 v3.1.12
Signature
arel_attributes_values(include_primary_key = true, include_readonly_attributes = true, attribute_names = @attributes.keys)
Returns a copy of the attributes hash where all the values have been safely quoted for use in an Arel insert/update method.
Parameters
-
include_primary_keyopt = true -
include_readonly_attributesopt = true -
attribute_namesopt = @attributes.keys
Source
# File activerecord/lib/active_record/base.rb, line 1980
def arel_attributes_values(include_primary_key = true, include_readonly_attributes = true, attribute_names = @attributes.keys)
attrs = {}
klass = self.class
arel_table = klass.arel_table
attribute_names.each do |name|
if (column = column_for_attribute(name)) && (include_primary_key || !column.primary)
if include_readonly_attributes || (!include_readonly_attributes && !self.class.readonly_attributes.include?(name))
value = if coder = klass.serialized_attributes[name]
coder.dump @attributes[name]
else
# FIXME: we need @attributes to be used consistently.
# If the values stored in @attributes were already type
# casted, this code could be simplified
read_attribute(name)
end
attrs[arel_table[name]] = value
end
end
end
attrs
end
Defined in activerecord/lib/active_record/base.rb line 1980
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::Base