From 5d61bef881189ed1ab6cf8df884123f2990fb089 Mon Sep 17 00:00:00 2001 From: Toru Takahashi Date: Wed, 9 May 2018 23:45:59 +0900 Subject: [PATCH] [phase-5]refactored redirect and flash message to oneline --- app/controllers/glossary_categories_controller.rb | 6 ++---- app/controllers/glossary_terms_controller.rb | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/app/controllers/glossary_categories_controller.rb b/app/controllers/glossary_categories_controller.rb index 0f0f289..a73b0db 100644 --- a/app/controllers/glossary_categories_controller.rb +++ b/app/controllers/glossary_categories_controller.rb @@ -19,16 +19,14 @@ class GlossaryCategoriesController < ApplicationController def create category = GlossaryCategory.new(glossary_category_params) if category.save - flash[:notice] = l(:notice_successful_create) - redirect_to category + redirect_to category, notice: l(:notice_successful_create) end end def update @category.attributes = glossary_category_params if @category.save - flash[:notice] = l(:notice_successful_update) - redirect_to @category + redirect_to @category, notice: l(:notice_successful_update) end rescue ActiveRecord::StaleObjectError flash.now[:error] = l(:notice_locking_conflict) diff --git a/app/controllers/glossary_terms_controller.rb b/app/controllers/glossary_terms_controller.rb index b31f7eb..fa32ca2 100644 --- a/app/controllers/glossary_terms_controller.rb +++ b/app/controllers/glossary_terms_controller.rb @@ -13,8 +13,7 @@ class GlossaryTermsController < ApplicationController def create term = GlossaryTerm.new(glossary_term_params) if term.save - flash[:notice] = l(:notice_successful_create) - redirect_to term + redirect_to term, notice: l(:notice_successful_create) end end @@ -24,8 +23,7 @@ class GlossaryTermsController < ApplicationController def update @term.attributes = glossary_term_params if @term.save - flash[:notice] = l(:notice_successful_update) - redirect_to @term + redirect_to @term, notice: l(:notice_successful_update) end rescue ActiveRecord::StaleObjectError flash.now[:error] = l(:notice_locking_conflict)