From fd2ceda5a4abf0ccf9611a9fde222c3ea2995094 Mon Sep 17 00:00:00 2001 From: uu59 Date: Thu, 31 Jul 2014 17:25:31 +0900 Subject: [PATCH] Display success flash should be succeed only --- app/controllers/fluentd/agents_controller.rb | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/app/controllers/fluentd/agents_controller.rb b/app/controllers/fluentd/agents_controller.rb index 2829fe8..bf575f3 100644 --- a/app/controllers/fluentd/agents_controller.rb +++ b/app/controllers/fluentd/agents_controller.rb @@ -2,26 +2,29 @@ class Fluentd::AgentsController < ApplicationController before_action :find_fluentd def start - unless @fluentd.agent.start + if @fluentd.agent.start + flash[:success] = t("messages.fluentd_start_stop_delay_notice", action: t('fluentd.common.start')) + else flash[:error] = t("messages.fluentd_start_failed", brand: fluentd_ui_title) + @fluentd.agent.log_tail(1).first end - flash[:success] = t("messages.fluentd_start_stop_delay_notice", action: t('fluentd.common.start')) redirect_to daemon_path(@fluentd), status: 303 # 303 is change HTTP Verb GET end def stop - unless @fluentd.agent.stop + if @fluentd.agent.stop + flash[:success] = t("messages.fluentd_start_stop_delay_notice", action: t('fluentd.common.stop')) + else flash[:error] = t("messages.fluentd_stop_failed", brand: fluentd_ui_title) end - flash[:success] = t("messages.fluentd_start_stop_delay_notice", action: t('fluentd.common.stop')) redirect_to daemon_path(@fluentd), status: 303 # 303 is change HTTP Verb GET end def restart - unless @fluentd.agent.restart + if @fluentd.agent.restart + flash[:success] = t("messages.fluentd_start_stop_delay_notice", action: t('fluentd.common.restart')) + else flash[:error] = t("messages.fluentd_restart_failed", brand: fluentd_ui_title) + @fluentd.agent.log_tail(1).first end - flash[:success] = t("messages.fluentd_start_stop_delay_notice", action: t('fluentd.common.restart')) redirect_to daemon_path(@fluentd), status: 303 # 303 is change HTTP Verb GET end