Rails 3: Validate IP String

Just wanted to add that instead of writing your own pattern you can use the build in one Resolv::IPv4::Regex

require 'resolv'

validates :gateway, :presence => true, :uniqueness => true,
  :format => { :with => Resolv::IPv4::Regex }

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)