OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Refactor `@type` setter into `before_action`
Aaron Contrerasc9455735f3da
diff --git a/app/controllers/types_controller.rb b/app/controllers/types_controller.rbindex 1cdb80ac054..d4bbdcd7bcc 100644--- a/app/controllers/types_controller.rb+++ b/app/controllers/types_controller.rb@@ -32,6 +32,7 @@ class TypesController < ApplicationControllerlayout 'admin'before_action :require_admin+ before_action :find_type, only: %i[update move destroy]def index@types = ::Type.page(page_param).per_page(per_page_param)@@ -78,8 +79,6 @@ class TypesController < ApplicationControllerenddef update- @type = ::Type.find(params[:id])-UpdateTypeService.new(@type, current_user).call(permitted_type_params) do |call|@@ -95,8 +94,6 @@ class TypesController < ApplicationControllerenddef move- @type = ::Type.find(params[:id])-if @type.update(permitted_params.type_move)flash[:notice] = I18n.t(:notice_successful_update)redirect_to types_path@@ -107,7 +104,6 @@ class TypesController < ApplicationControllerenddef destroy- @type = ::Type.find(params[:id])# types cannot be deleted when they have work packages# or they are standard types# put that into the model and do a `if @type.destroy`@@ -122,6 +118,10 @@ class TypesController < ApplicationControllerprotected+ def find_type+ @type = ::Type.find(params[:id])+ end+def permitted_type_params# having to call #to_unsafe_h as a query hash the attribute_groups# parameters would otherwise still be an ActiveSupport::Parameter@@ -160,7 +160,7 @@ class TypesController < ApplicationControllerenddef update_success_message- if params[:tab].in?(["form_configuration", "projects"])+ if params[:tab].in?(%w[form_configuration projects])t(:notice_successful_update_custom_fields_added_to_type)elset(:notice_successful_update)