Do not use ActiveRecord::Base.new(hsh) when instantiating AR models. Use form of instantiation that allows protected attributes to be set.
This commit is contained in:
parent
71184b2903
commit
5aefbb2989
|
@ -245,7 +245,9 @@ class ActiveRecord::Base
|
||||||
# keep track of the instance and the position it is currently at. if this fails
|
# keep track of the instance and the position it is currently at. if this fails
|
||||||
# validation we'll use the index to remove it from the array_of_attributes
|
# validation we'll use the index to remove it from the array_of_attributes
|
||||||
arr.each_with_index do |hsh,i|
|
arr.each_with_index do |hsh,i|
|
||||||
instance = new( hsh )
|
instance = new do |model|
|
||||||
|
hsh.each_pair{ |k,v| model.send("#{k}=", v) }
|
||||||
|
end
|
||||||
if not instance.valid?
|
if not instance.valid?
|
||||||
array_of_attributes[ i ] = nil
|
array_of_attributes[ i ] = nil
|
||||||
failed_instances << instance
|
failed_instances << instance
|
||||||
|
|
Loading…
Reference in a new issue