[phase-5]refactored redirect and flash message to oneline

This commit is contained in:
Toru Takahashi 2018-05-09 23:45:59 +09:00 committed by TAKAHASHI,Toru
parent 06cc4908a5
commit 5d61bef881
2 changed files with 4 additions and 8 deletions

View File

@ -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)

View File

@ -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)