From 7ebd27c74dcc24fd40b54a171372b08f771caa34 Mon Sep 17 00:00:00 2001 From: Toru Takahashi Date: Wed, 23 May 2018 04:15:31 +0900 Subject: [PATCH] [refactoring]changed calling method to find project to use redmine's standard method. --- app/controllers/glossary_categories_controller.rb | 9 +-------- app/controllers/glossary_terms_controller.rb | 9 +-------- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/app/controllers/glossary_categories_controller.rb b/app/controllers/glossary_categories_controller.rb index 02eb7f5..be5289c 100644 --- a/app/controllers/glossary_categories_controller.rb +++ b/app/controllers/glossary_categories_controller.rb @@ -1,7 +1,7 @@ class GlossaryCategoriesController < ApplicationController before_action :find_category_from_id, only: [:show, :edit, :update, :destroy] - before_action :find_project_from_id, :authorize + before_action :find_project_by_project_id, :authorize def index @categories = GlossaryCategory.where(project_id: @project.id) @@ -48,13 +48,6 @@ class GlossaryCategoriesController < ApplicationController private - # Find the project whose id is the :project_id parameter - def find_project_from_id - @project = Project.find(params[:project_id]) - rescue ActiveRecord::RecordNotFound - render_404 - end - def glossary_category_params params.require(:glossary_category).permit( :name diff --git a/app/controllers/glossary_terms_controller.rb b/app/controllers/glossary_terms_controller.rb index 4822091..5f47470 100644 --- a/app/controllers/glossary_terms_controller.rb +++ b/app/controllers/glossary_terms_controller.rb @@ -1,7 +1,7 @@ class GlossaryTermsController < ApplicationController before_action :find_term_from_id, only: [:show, :edit, :update, :destroy] - before_action :find_project_from_id, :authorize + before_action :find_project_by_project_id, :authorize def index @glossary_terms = GlossaryTerm.where(project_id: @project.id) @@ -44,13 +44,6 @@ class GlossaryTermsController < ApplicationController render_404 end - # Find the project whose id is the :project_id parameter - def find_project_from_id - @project = Project.find(params[:project_id]) - rescue ActiveRecord::RecordNotFound - render_404 - end - private def glossary_term_params