Show exceptions if updating note fails.

This commit is contained in:
hassaku 2015-01-07 17:34:02 +09:00
parent 336e22bea7
commit 9cc12f7bc3
4 changed files with 5 additions and 17 deletions

View File

@ -4,12 +4,8 @@ class Fluentd::Settings::NotesController < ApplicationController
before_action :find_note, only: [:update]
def update
if @note.update(params[:note][:content])
flash[:success] = t('messages.note_updating_success')
else
flash[:error] = t('errors.messages.note_updating_failed')
end
redirect_to daemon_setting_path
@note.update!(params[:note][:content])
redirect_to daemon_setting_path, flash: { success: t('messages.note_updating_success') }
end
private

View File

@ -18,16 +18,10 @@ class Fluentd
@file_path = file_path
end
def update(content)
begin
File.open(@file_path, "w") do |f|
f.write content
end
rescue => ex
Rails.logger.error ex.message
return false
def update!(content)
File.open(@file_path, "w") do |f|
f.write content
end
true
end
end
end

View File

@ -287,7 +287,6 @@ en:
is_a_directory: is a directory. should be a file
duplicated_conf: Configurations is duplicated
out_forward_blank_server: server settings should be at least one
note_updating_failed: Updating the note is failed. See application logs.
activemodel: &activemodel
errors:

View File

@ -292,7 +292,6 @@ ja:
is_a_directory: はディレクトリです。ファイルを指定してください
duplicated_conf: 同じ内容の設定がすでに存在しています
out_forward_blank_server: serverの設定がありません。
note_updating_failed: メモの更新に失敗しました。ログを確認して下さい。
activemodel: &activemodel
errors: