[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 def create
category = GlossaryCategory.new(glossary_category_params) category = GlossaryCategory.new(glossary_category_params)
if category.save if category.save
flash[:notice] = l(:notice_successful_create) redirect_to category, notice: l(:notice_successful_create)
redirect_to category
end end
end end
def update def update
@category.attributes = glossary_category_params @category.attributes = glossary_category_params
if @category.save if @category.save
flash[:notice] = l(:notice_successful_update) redirect_to @category, notice: l(:notice_successful_update)
redirect_to @category
end end
rescue ActiveRecord::StaleObjectError rescue ActiveRecord::StaleObjectError
flash.now[:error] = l(:notice_locking_conflict) flash.now[:error] = l(:notice_locking_conflict)

View File

@ -13,8 +13,7 @@ class GlossaryTermsController < ApplicationController
def create def create
term = GlossaryTerm.new(glossary_term_params) term = GlossaryTerm.new(glossary_term_params)
if term.save if term.save
flash[:notice] = l(:notice_successful_create) redirect_to term, notice: l(:notice_successful_create)
redirect_to term
end end
end end
@ -24,8 +23,7 @@ class GlossaryTermsController < ApplicationController
def update def update
@term.attributes = glossary_term_params @term.attributes = glossary_term_params
if @term.save if @term.save
flash[:notice] = l(:notice_successful_update) redirect_to @term, notice: l(:notice_successful_update)
redirect_to @term
end end
rescue ActiveRecord::StaleObjectError rescue ActiveRecord::StaleObjectError
flash.now[:error] = l(:notice_locking_conflict) flash.now[:error] = l(:notice_locking_conflict)