From 7b911245d31509da8fa656bbedc37213d3148897 Mon Sep 17 00:00:00 2001 From: Marius Balteanu Date: Mon, 27 Nov 2023 20:58:55 +0000 Subject: Updates Rails to 7.1.2 (#36320). Patch by Takashi Kato. git-svn-id: https://svn.redmine.org/redmine/trunk@22488 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- config/initializers/10-patches.rb | 50 ++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 22 deletions(-) (limited to 'config/initializers/10-patches.rb') diff --git a/config/initializers/10-patches.rb b/config/initializers/10-patches.rb index 4bca5edf4..adac86583 100644 --- a/config/initializers/10-patches.rb +++ b/config/initializers/10-patches.rb @@ -47,20 +47,6 @@ module ActionView end end end - - class Resolver - def find_all(name, prefix=nil, partial=false, details={}, key=nil, locals=[]) - locals = locals.map(&:to_s).sort!.freeze - - cached(key, [name, prefix, partial], details, locals) do - if (details[:formats] & [:xml, :json]).any? - details = details.dup - details[:formats] = details[:formats].dup + [:api] - end - _find_all(name, prefix, partial, details, key, locals) - end - end - end end ActionView::Base.field_error_proc = Proc.new{ |html_tag, instance| html_tag || ''.html_safe } @@ -69,17 +55,14 @@ ActionView::Base.field_error_proc = Proc.new{ |html_tag, instance| html_tag || ' module ActionView module Helpers module Tags - class Base - private - alias :add_options_without_non_empty_blank_option :add_options + SelectRenderer.prepend(Module.new do def add_options(option_tags, options, value = nil) - if options[:include_blank] == true - options = options.dup - options[:include_blank] = ' '.html_safe + if options.delete(:include_blank) + options[:prompt] = ' '.html_safe end - add_options_without_non_empty_blank_option(option_tags, options, value) + super end - end + end) end module FormHelper @@ -156,6 +139,29 @@ module ActionController end end +module ActionView + LookupContext.prepend(Module.new do + def formats=(values) + if (Array(values) & [:xml, :json]).any? + values << :api + end + super values + end + end) + + Rendering.prepend(Module.new do + def rendered_format + if lookup_context.formats.first == :api + return request.format + end + + super + end + end) +end + +Mime::SET << 'api' + # Adds asset_id parameters to assets like Rails 3 to invalidate caches in browser module ActionView module Helpers -- cgit v1.2.3