Screened ip address can be edited, deleted, and changed to allow or block.

This commit is contained in:
Neil Lalonde
2013-10-22 16:30:30 -04:00
parent b8d586251c
commit 7d582fbee3
16 changed files with 259 additions and 16 deletions

View File

@ -0,0 +1,11 @@
# Allows unique IP address (10.0.1.20), and IP addresses with a mask (10.0.0.0/8).
# Useful when storing in a Postgresql inet column.
class IpAddressFormatValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
unless record.ip_address.nil? or record.ip_address.split('/').first =~ Resolv::AddressRegex
record.errors.add(attribute, :invalid)
end
end
end