aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorPaul Nikitochkin <paul.nikitochkin@gmail.com>2013-07-23 22:33:53 +0300
committerPaul Nikitochkin <paul.nikitochkin@gmail.com>2013-08-14 21:04:31 +0300
commit0aa95a71b04f2893921c58a7c1d9fca60dbdcbc2 (patch)
treeabd1693a29584a18288438b495ca5018e6265660 /activerecord/lib
parent41f50beb7e10e186522ac99f1f1586c21eefd93b (diff)
downloadrails-0aa95a71b04f2893921c58a7c1d9fca60dbdcbc2.tar.gz
rails-0aa95a71b04f2893921c58a7c1d9fca60dbdcbc2.tar.bz2
rails-0aa95a71b04f2893921c58a7c1d9fca60dbdcbc2.zip
Rescue invalid ip address exceptions on assign.
In order that set attribute should not be bang method
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql/cast.rb6
1 files changed, 5 insertions, 1 deletions
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