From 3ed9438a004eae5abda923c5209bd2e8667f9d3f Mon Sep 17 00:00:00 2001 From: Adam Cooke Date: Thu, 27 Apr 2017 10:34:22 +0100 Subject: [PATCH] fixes issue with creating new organizations when there are no ip pools --- app/models/organization.rb | 4 +++- db/seeds.rb | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/models/organization.rb b/app/models/organization.rb index c9cb986..54dbab9 100644 --- a/app/models/organization.rb +++ b/app/models/organization.rb @@ -48,7 +48,9 @@ class Organization < ApplicationRecord has_many :ip_pool_rules, :dependent => :destroy, :as => :owner after_create do - self.ip_pools << IPPool.transactional.default + if pool = IPPool.transactional.default + self.ip_pools << IPPool.transactional.default + end end def status diff --git a/db/seeds.rb b/db/seeds.rb index 2e840db..7fca864 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -3,4 +3,4 @@ user = User.create!(:first_name => "Example", :last_name => "Admin", :email_addr org = Organization.create!(:name => "Acme Inc", :permalink => "acme", :time_zone => "London", :owner => user) org.users << user -server = Server.create!(:ip_pool => ip_pool, :organization => org, :name => "Example Server", :permalink => "example", :mode => "Live") +server = Server.create!(:organization => org, :name => "Example Server", :permalink => "example", :mode => "Live")