[PATCH/foreman 2/2] fixes 1432 - subnet gateway infos only saved when fill gateway and dns fields

the informations in the subnet form only saved if you fill the gateway and one dns fields
the cause is the validation in models/subnets.rb

whyever the :allow_blank should work, but i need to add :allow_nil also to get this working

Signed-off-by: Florian Koch <florian.koch1981@googlemail.com>

··· --- app/models/subnet.rb | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/app/models/subnet.rb b/app/models/subnet.rb
index 10ccfd9…ea81e92 100644
— a/app/models/subnet.rb
+++ b/app/models/subnet.rb
@@ -10,7 +10,7 @@ class Subnet < ActiveRecord::Base
validates_presence_of :network, :mask, :domain_id, :name
validates_uniqueness_of :network
validates_format_of :network, :mask, :with => Net::Validations::IP_REGEXP

  • validates_format_of :gateway, :dns_primary, :dns_secondary, :with => Net::Validations::IP_REGEXP, :allow_blank => true
  • validates_format_of :gateway, :dns_primary, :dns_secondary, :with => Net::Validations::IP_REGEXP, :allow_blank => true, :allow_nil => true
    validates_uniqueness_of :name, :scope => :domain_id
    default_scope :order => 'priority’
    validate :validate_ranges

    1.7.6.5