Skip to content

Commit

Permalink
fixes issue with creating new organizations when there are no ip pools
Browse files Browse the repository at this point in the history
  • Loading branch information
adamcooke committed Apr 27, 2017
1 parent 10794f8 commit 3ed9438
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion app/models/organization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
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")

0 comments on commit 3ed9438

Please sign in to comment.