Use short syntax for the translations in DocumentsController

This commit is contained in:
Patrick Gansterer 2017-10-11 01:37:40 +02:00
parent f27bbc2ffa
commit 9a3ab1458e

View file

@ -35,21 +35,21 @@ class DocumentsController < ApplicationController
end end
@document.created_by = current_user @document.created_by = current_user
@document.save! @document.save!
redirect_to documents_path, notice: I18n.t('documents.create.notice') redirect_to documents_path, notice: t('.notice')
rescue => error rescue => error
redirect_to documents_path, alert: t('documents.create.error', error: error.message) redirect_to documents_path, alert: t('.error', error: error.message)
end end
def destroy def destroy
@document = Document.find(params[:id]) @document = Document.find(params[:id])
if @document.created_by == current_user or current_user.role_admin? if @document.created_by == current_user or current_user.role_admin?
@document.destroy @document.destroy
redirect_to documents_path, notice: t('documents.destroy.notice') redirect_to documents_path, notice: t('.notice')
else else
redirect_to documents_path, alert: t('documents.destroy.no_right') redirect_to documents_path, alert: t('.no_right')
end end
rescue => error rescue => error
redirect_to documents_path, alert: t('documents.destroy.error', error: error.message) redirect_to documents_path, alert: t('.error', error: error.message)
end end
def show def show