Fixes for postgresql inet columns in Rails 4. They're backed by an IPAddr class now, which breaks sql parameter marker support, and automatically sets the attribute to nil when trying to assign an invalid ip address.

This commit is contained in:
Neil Lalonde
2013-10-22 18:55:30 -04:00
parent 6394d924c8
commit c1008f4359
5 changed files with 21 additions and 7 deletions

View File

@@ -21,7 +21,7 @@ class ScreenedIpAddress < ActiveRecord::Base
#
# http://www.postgresql.org/docs/9.1/static/datatype-net-types.html
# http://www.postgresql.org/docs/9.1/static/functions-net.html
where('? <<= ip_address', ip_address).first
where("'#{ip_address.to_s}' <<= ip_address").first
end
def self.should_block?(ip_address)