From 7ce103c1dd4df2c2dd1baeb462370e14c46aeb80 Mon Sep 17 00:00:00 2001 From: Oleh Fedorenko Date: Fri, 20 Sep 2024 13:40:41 +0000 Subject: [PATCH] Fixes #37847 - Support Rails 7.0 --- app/helpers/job_invocations_helper.rb | 2 +- .../concerns/foreman_remote_execution/errors_flattener.rb | 4 ++-- app/views/template_invocations/show.html.erb | 2 +- lib/foreman_remote_execution/engine.rb | 4 ---- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/app/helpers/job_invocations_helper.rb b/app/helpers/job_invocations_helper.rb index 05889c1b7..378ca2c1d 100644 --- a/app/helpers/job_invocations_helper.rb +++ b/app/helpers/job_invocations_helper.rb @@ -33,7 +33,7 @@ def preview_hosts(template_invocation) end def collapsed_preview(target) - title = target || 'N/A' + title = (target || 'N/A').to_s content_tag(:h5, :class => "expander collapsed out", :data => { :toggle => 'collapse', diff --git a/app/models/concerns/foreman_remote_execution/errors_flattener.rb b/app/models/concerns/foreman_remote_execution/errors_flattener.rb index 47b1d83e6..7e97e8ebd 100644 --- a/app/models/concerns/foreman_remote_execution/errors_flattener.rb +++ b/app/models/concerns/foreman_remote_execution/errors_flattener.rb @@ -7,8 +7,8 @@ def flattened_validation_exception def flattened_errors errors = Hash.new { |h, k| h[k] = [] } # self.errors is ActiveModel::Errors, not Hash and doesn't have the #each_key method - self.errors.keys.each do |key| - messages = self.errors[key] + self.errors.attribute_names.each do |key| + messages = self.errors.messages_for(key) invalid_objects = invalid_objects_for_attribute(key) if invalid_objects.blank? errors[key] = messages diff --git a/app/views/template_invocations/show.html.erb b/app/views/template_invocations/show.html.erb index e07dd4e5a..eda919b5e 100644 --- a/app/views/template_invocations/show.html.erb +++ b/app/views/template_invocations/show.html.erb @@ -55,7 +55,7 @@ end <% else %> <%= _("Could not display data for job invocation.") %> diff --git a/lib/foreman_remote_execution/engine.rb b/lib/foreman_remote_execution/engine.rb index 87d8b5d1e..b0e5f90db 100644 --- a/lib/foreman_remote_execution/engine.rb +++ b/lib/foreman_remote_execution/engine.rb @@ -4,10 +4,6 @@ module ForemanRemoteExecution class Engine < ::Rails::Engine engine_name 'foreman_remote_execution' - config.autoload_paths += Dir["#{config.root}/app/controllers/concerns"] - config.autoload_paths += Dir["#{config.root}/app/helpers/concerns"] - config.autoload_paths += Dir["#{config.root}/app/models/concerns"] - # Precompile any JS or CSS files under app/assets/ # If requiring files from each other, list them explicitly here to avoid precompiling the same # content twice.