diff --git a/app/controllers/projects/clusters/applications_controller.rb b/app/controllers/projects/clusters/applications_controller.rb index 6de7a332164..ce04c186dc0 100644 --- a/app/controllers/projects/clusters/applications_controller.rb +++ b/app/controllers/projects/clusters/applications_controller.rb @@ -5,17 +5,18 @@ class Projects::Clusters::ApplicationsController < Projects::ApplicationControll before_action :authorize_create_cluster!, only: [:create] def create - application = @application_class.find_or_create_by!(cluster: @cluster) + application = @application_class.find_or_initialize_by(cluster: @cluster) - if application.respond_to?(:hostname) - application.update(hostname: params[:hostname]) + if has_attribute?(:hostname) + application.hostname = params[:hostname] end if application.respond_to?(:oauth_application) application.oauth_application = create_oauth_application(application) - application.save end + application.save! + Clusters::Applications::ScheduleInstallationService.new(project, current_user).execute(application) head :no_content