Skip to content

Commit af6b474

Browse files
committed
Handle setting preset scenario roles on create correctly
1 parent 1e7e523 commit af6b474

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

app/controllers/api/v3/scenarios_controller.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def create
173173
# The scaler needs to be in place before assigning attributes when the
174174
# scenario inherits from a preset.
175175
@scenario.descale = attrs[:descale]
176-
@scenario.attributes = attrs.except(:user_values)
176+
@scenario.attributes = attrs.except(:user_values, :set_preset_roles)
177177

178178
if current_user.present?
179179
@scenario.scenario_users.build(
@@ -186,10 +186,12 @@ def create
186186
Scenario.transaction do
187187
@scenario.save!
188188

189-
if attrs[:user_values].present?
189+
updater_scenario_params = attrs.slice(:user_values, :set_preset_roles).compact_blank
190+
191+
if updater_scenario_params.any?
190192
result = ::ScenarioUpdater.new(
191193
@scenario,
192-
{ scenario: { user_values: attrs[:user_values] } },
194+
{ scenario: updater_scenario_params },
193195
current_user
194196
).call
195197

0 commit comments

Comments
 (0)