Skip to content

Commit 2fa65a7

Browse files
committed
Explicitly set platform as host only during the platform setup wizard steps
Automatically setting host before validation was causing the first community created during the db seed step to be set as the host. Geography records have primary communities and prior to them being added there were no seeded communities.
1 parent a3c05d3 commit 2fa65a7

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

app/concerns/better_together/host.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ module Host
66
extend ActiveSupport::Concern
77

88
included do
9-
before_validation :set_as_host
9+
# before_validation :set_as_host # this was causing problems wdhen the seeds created communities
1010
validate :single_host_record
11+
12+
scope :host, -> { where(host: true) }
1113
end
1214

1315
def host?

app/controllers/better_together/setup_wizard_steps_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def create_host_platform # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
2727
ActiveRecord::Base.transaction do
2828
platform = base_platform
2929
platform.assign_attributes(platform_params)
30+
platform.set_as_host
3031

3132
if platform.save!
3233
mark_current_step_as_completed

0 commit comments

Comments
 (0)