From cf8daa5e0eef6660cf8e74da60e9ae4b293a9b17 Mon Sep 17 00:00:00 2001 From: Sergio Cambra Date: Thu, 21 Nov 2024 18:22:08 +0100 Subject: [PATCH] Deprecate ActiveScaffold.js_framework as will be removed in 4.0 --- CHANGELOG.rdoc | 1 + lib/active_scaffold.rb | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rdoc b/CHANGELOG.rdoc index 4c4926a32..8f4ba1545 100644 --- a/CHANGELOG.rdoc +++ b/CHANGELOG.rdoc @@ -3,6 +3,7 @@ - Add hidden field with locking column in base_form partial for persisted records automatically, if model uses optimistic locking. - Add on_stale_object_error when StaleObjectError is rescued, to allow customization. - Fix search_ui :select_multiple, which was broken when operator select was added. +- Deprecate ActiveScaffold.js_framework as will be removed in 4.0 = 3.7.8 - Rollback previous behaviour when submitting empty values, broken when default_value was added. Default value set in column is not used when trying to save empty value, DB default is used in that case, and save NULL when string is empty, as before. diff --git a/lib/active_scaffold.rb b/lib/active_scaffold.rb index 13cd31e3f..bd84521ff 100644 --- a/lib/active_scaffold.rb +++ b/lib/active_scaffold.rb @@ -56,7 +56,19 @@ def self.threadsafe! @@threadsafe = true end - mattr_writer :js_framework, instance_writer: false + def self.js_framework=(framework) + warning = 'js_framework is deprecated as prototype support will be removed in 4.0' + case framework + when :jquery then + if defined? Jquery + warning += ', it can be removed as it defaults to :jquery' + else + warning += ", it's still needed in this version, as you are not using jquery-rails gem" + end + when :prototype then ', convert your app to jQuery, and remove this call' + ActiveSupport::Deprecation.warn warning + @@js_framework = framework + end def self.js_framework @@js_framework ||= if defined? Jquery