From 0aa95a71b04f2893921c58a7c1d9fca60dbdcbc2 Mon Sep 17 00:00:00 2001 From: Paul Nikitochkin Date: Tue, 23 Jul 2013 22:33:53 +0300 Subject: Rescue invalid ip address exceptions on assign. In order that set attribute should not be bang method --- .../lib/active_record/connection_adapters/postgresql/cast.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'activerecord/lib/active_record') diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/cast.rb b/activerecord/lib/active_record/connection_adapters/postgresql/cast.rb index 56dc9ea813..ef7b976d4f 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql/cast.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql/cast.rb @@ -100,7 +100,11 @@ module ActiveRecord if string.nil? nil elsif String === string - IPAddr.new(string) + begin + IPAddr.new(string) + rescue ArgumentError + nil + end else string end -- cgit v1.2.3