URGENT FIX: code would fail in Ruby 1.9.3 exception does not exist

This commit is contained in:
Sam 2013-11-18 09:31:44 +11:00
parent 6eb5f1aec2
commit 1b19444b44
1 changed files with 4 additions and 1 deletions

View File

@ -19,7 +19,10 @@ class ScreenedIpAddress < ActiveRecord::Base
# inet/cidr columns:
def ip_address=(val)
write_attribute(:ip_address, val)
rescue IPAddr::InvalidAddressError
# this gets even messier, Ruby 1.9.2 raised a different exception to Ruby 2.0.0
# handle both exceptions
rescue ArgumentError, IPAddr::InvalidAddressError
self.errors.add(:ip_address, :invalid)
end