From be07d4d01dea50f586243e7c25477b6e283b0b9e Mon Sep 17 00:00:00 2001 From: Marius Balteanu Date: Sun, 28 Sep 2025 21:20:39 +0000 Subject: [PATCH] Fixes "ArgumentError: wrong number of arguments (given 0, expected 1) in ApplicationController#find_model_object" in Rails 8 (#43205, #43230). Patch by Katsuya HIDAKA (user:hidakatsuya). git-svn-id: https://svn.redmine.org/redmine/trunk@24017 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/application_controller.rb | 4 ---- app/controllers/comments_controller.rb | 3 ++- app/controllers/documents_controller.rb | 3 ++- app/controllers/issue_categories_controller.rb | 3 ++- app/controllers/members_controller.rb | 3 ++- app/controllers/news_controller.rb | 3 ++- app/controllers/versions_controller.rb | 3 ++- 7 files changed, 12 insertions(+), 10 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index a01d5c75f..d06344c0a 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -389,10 +389,6 @@ class ApplicationController < ActionController::Base render_404 end - def self.model_object(model) - self.model_object = model - end - # Find the issue whose id is the :id parameter # Raises a Unauthorized exception if the issue is not visible def find_issue diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index 4043db08b..d04b5ed8d 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -18,8 +18,9 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class CommentsController < ApplicationController + self.model_object = News + default_search_scope :news - model_object News before_action :find_model_object before_action :find_project_from_association before_action :authorize diff --git a/app/controllers/documents_controller.rb b/app/controllers/documents_controller.rb index bd6c3f461..4e2c255d5 100644 --- a/app/controllers/documents_controller.rb +++ b/app/controllers/documents_controller.rb @@ -18,8 +18,9 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class DocumentsController < ApplicationController + self.model_object = Document + default_search_scope :documents - model_object Document before_action :find_project_by_project_id, :only => [:index, :new, :create] before_action :find_model_object, :except => [:index, :new, :create] before_action :find_project_from_association, :except => [:index, :new, :create] diff --git a/app/controllers/issue_categories_controller.rb b/app/controllers/issue_categories_controller.rb index 6148fe663..b184d0ac1 100644 --- a/app/controllers/issue_categories_controller.rb +++ b/app/controllers/issue_categories_controller.rb @@ -18,8 +18,9 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class IssueCategoriesController < ApplicationController + self.model_object = IssueCategory + menu_item :settings - model_object IssueCategory before_action :find_model_object, :except => [:index, :new, :create] before_action :find_project_from_association, :except => [:index, :new, :create] before_action :find_project_by_project_id, :only => [:index, :new, :create] diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index 3f7b376c6..db2a2be7b 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -18,7 +18,8 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class MembersController < ApplicationController - model_object Member + self.model_object = Member + before_action :find_model_object, :except => [:index, :new, :create, :autocomplete] before_action :find_project_from_association, :except => [:index, :new, :create, :autocomplete] before_action :find_project_by_project_id, :only => [:index, :new, :create, :autocomplete] diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb index dd6bade24..57e0ff28d 100644 --- a/app/controllers/news_controller.rb +++ b/app/controllers/news_controller.rb @@ -18,8 +18,9 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class NewsController < ApplicationController + self.model_object = News + default_search_scope :news - model_object News before_action :find_model_object, :except => [:new, :create, :index] before_action :find_project_from_association, :except => [:new, :create, :index] before_action :find_project_by_project_id, :only => :create diff --git a/app/controllers/versions_controller.rb b/app/controllers/versions_controller.rb index 328d3e56e..bdc909d25 100644 --- a/app/controllers/versions_controller.rb +++ b/app/controllers/versions_controller.rb @@ -18,8 +18,9 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class VersionsController < ApplicationController + self.model_object = Version + menu_item :roadmap - model_object Version before_action :find_model_object, :except => [:index, :new, :create, :close_completed] before_action :find_project_from_association, :except => [:index, :new, :create, :close_completed] before_action :find_project_by_project_id, :only => [:index, :new, :create, :close_completed]