FIX: creating an automation without script should error (#28752)

This commit ensure we are properly showing an error to the end user and not just a vague 500.
This commit is contained in:
Joffrey JAFFEUX
2024-09-05 11:18:38 +02:00
committed by GitHub
parent 1a96269be0
commit 67ce50c141
3 changed files with 48 additions and 1 deletions

View File

@ -27,7 +27,8 @@ module DiscourseAutomation
DiscourseAutomation::Automation.new(
automation_params.merge(last_updated_by_id: current_user.id),
)
if automation.scriptable.forced_triggerable
if automation.scriptable&.forced_triggerable
automation.trigger = scriptable.forced_triggerable[:triggerable].to_s
end