From 502ba94465b1d0515f9bbcf2bc092d9f8b2d0d7c Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Mon, 9 Feb 2026 14:12:01 -0500 Subject: [PATCH] Readded missing controller_issues_new_before_save --- lib/redmine_qbo/patches/issues_controller_patch.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/redmine_qbo/patches/issues_controller_patch.rb b/lib/redmine_qbo/patches/issues_controller_patch.rb index eef439f..7b9b79d 100644 --- a/lib/redmine_qbo/patches/issues_controller_patch.rb +++ b/lib/redmine_qbo/patches/issues_controller_patch.rb @@ -14,6 +14,19 @@ module RedmineQbo module IssuesControllerPatch module Helper + + # Check the new issue form for a valid project. + # This is added to help prevent 422 unprocessable entity errors when creating an issue + # See https://github.com/redmine/redmine/blob/84483d63828d0cb2efbf5bd786a2f0d22e34c93d/app/controllers/issues_controller.rb#L179 + def controller_issues_new_before_save(context={}) + if context[:issue].project.nil? + context[:issue].project = projects_for_select(context[:issue]).first + context[:controller].flash[:error] = I18n.t(:notice_error_project_nil) + context[:issue].project.to_s + end + + return context + end + def watcher_link(issue, user) link = '' link = link_to(I18n.t(:label_bill_time), bill_path( issue.id ), method: :get, class: 'icon icon-email-add') if user.admin?