I'm upgrading an application from Rails 3.0 to 3.1 and found the following error showing up in my tests:
NoMethodError: undefined method `delete' for #<ActiveModel::Errors:0x007f928c0ee310>
I have the following snippet that moves errors :
after_validation do
self.errors[:image_size].each do |message|
self.errors.add(:image, message)
end
self.errors[:image_extension].each do |message|
self.errors.add(:image, message)
end
self.errors.delete(:image_size)
self.errors.delete(:image_extension)
end
I still need to be able to move all validations from image_size
and image_extension
, but I'm not sure how do this in Rails 3.1. Any ideas?
The only method that removes anything is clear
and the removes everything so I think you have to:
to_hash
).self.errors.clear
.self.errors.add
.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With