Avoid Base#attributes when saving / creating records. Closes #10978 [adymo]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8770 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
Michael Koziarski 2008-02-01 23:15:57 +00:00
parent 0d26e47b29
commit 6d39d05269

@ -2426,11 +2426,11 @@ def attributes_protected_by_default
# Returns a copy of the attributes hash where all the values have been safely quoted for use in
# an SQL statement.
def attributes_with_quotes(include_primary_key = true, include_readonly_attributes = true)
quoted = attributes.inject({}) do |result, (name, value)|
quoted = {}
@attributes.each_pair do |name, value|
if column = column_for_attribute(name)
result[name] = quote_value(value, column) unless !include_primary_key && column.primary
quoted[name] = quote_value(read_attribute(name), column) unless !include_primary_key && column.primary
end
result
end
include_readonly_attributes ? quoted : remove_readonly_attributes(quoted)
end