From 4e3cb16f7dc9bd56c6ac53b81721abf3f8a4e9d6 Mon Sep 17 00:00:00 2001 From: Will Leonard Date: Tue, 25 Apr 2023 10:54:08 -0400 Subject: [PATCH 01/11] >= 3.2 instead of ~> --- active_scaffold.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/active_scaffold.gemspec b/active_scaffold.gemspec index cb472dcfed..85fb383ac4 100644 --- a/active_scaffold.gemspec +++ b/active_scaffold.gemspec @@ -25,6 +25,6 @@ Gem::Specification.new do |s| s.add_development_dependency(%q, ["~> 1.0.0"]) s.add_development_dependency(%q, [">= 0"]) #s.add_runtime_dependency(%q, [">= 0"]) - s.add_runtime_dependency(%q, "~> 3.2.0") + s.add_runtime_dependency(%q, ">= 3.2.0") end From 7a5b9953be5bb0b7cf86ae7fbded113e467be658 Mon Sep 17 00:00:00 2001 From: Will Leonard Date: Tue, 25 Apr 2023 12:12:16 -0400 Subject: [PATCH 02/11] Remove arbitrary version check --- lib/active_scaffold.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/active_scaffold.rb b/lib/active_scaffold.rb index 19cba834f6..2ef4102dea 100644 --- a/lib/active_scaffold.rb +++ b/lib/active_scaffold.rb @@ -1,7 +1,3 @@ -unless Rails::VERSION::MAJOR == 3 && Rails::VERSION::MINOR >= 1 - raise "This version of ActiveScaffold requires Rails 3.1 or higher. Please use an earlier version." -end - begin require 'render_component' rescue LoadError From 5090967a27cbe401ae34ca23a1a687066bf6a52f Mon Sep 17 00:00:00 2001 From: Will Leonard Date: Tue, 25 Apr 2023 12:22:53 -0400 Subject: [PATCH 03/11] Do this --- .../extensions/name_option_for_datetime.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/active_scaffold/extensions/name_option_for_datetime.rb b/lib/active_scaffold/extensions/name_option_for_datetime.rb index 48c4580cd1..b8ef75a2f1 100644 --- a/lib/active_scaffold/extensions/name_option_for_datetime.rb +++ b/lib/active_scaffold/extensions/name_option_for_datetime.rb @@ -1,6 +1,6 @@ -module ActionView - module Helpers - class InstanceTag +module ActiveScaffold + module Extensions + module NameOptionForDatetime private def datetime_selector_with_name(options, html_options) options.merge!(:prefix => options[:name].gsub(/\[[^\[]*\]$/,'')) if options[:name] @@ -10,3 +10,6 @@ def datetime_selector_with_name(options, html_options) end end end + +klass = defined?(ActionView::Helpers::InstanceTag) ? ActionView::Helpers::InstanceTag : ActionView::Helpers::Tags::DateSelect +klass.include(ActiveScaffold::DateSelectExtension) From 8b635c7074cce43d0aeb0090c67b9bc8317888eb Mon Sep 17 00:00:00 2001 From: Will Leonard Date: Tue, 25 Apr 2023 12:30:33 -0400 Subject: [PATCH 04/11] Fix this too --- .../extensions/name_option_for_datetime.rb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/active_scaffold/extensions/name_option_for_datetime.rb b/lib/active_scaffold/extensions/name_option_for_datetime.rb index b8ef75a2f1..59e5edfcda 100644 --- a/lib/active_scaffold/extensions/name_option_for_datetime.rb +++ b/lib/active_scaffold/extensions/name_option_for_datetime.rb @@ -1,15 +1,20 @@ -module ActiveScaffold +module ActiveScaffold module Extensions module NameOptionForDatetime - private + def self.included(base) + base.class_eval do + alias_method_chain :datetime_selector, :name + private :datetime_selector_without_name, :datetime_selector_with_name, :datetime_selector + end + end + def datetime_selector_with_name(options, html_options) options.merge!(:prefix => options[:name].gsub(/\[[^\[]*\]$/,'')) if options[:name] datetime_selector_without_name(options, html_options) end - alias_method_chain :datetime_selector, :name end end end klass = defined?(ActionView::Helpers::InstanceTag) ? ActionView::Helpers::InstanceTag : ActionView::Helpers::Tags::DateSelect -klass.include(ActiveScaffold::DateSelectExtension) +klass.include(ActiveScaffold::Extensions::NameOptionForDatetime) From 1d30703165530b822cf76ec5ec70d80a94fb42d8 Mon Sep 17 00:00:00 2001 From: Will Leonard Date: Wed, 26 Apr 2023 14:16:53 -0400 Subject: [PATCH 05/11] How about this too --- lib/active_scaffold.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/active_scaffold.rb b/lib/active_scaffold.rb index 2ef4102dea..981bb4b946 100644 --- a/lib/active_scaffold.rb +++ b/lib/active_scaffold.rb @@ -183,7 +183,7 @@ def active_scaffold(model_id = nil, &block) # defines the attribute read methods on the model, so record.send() doesn't find protected/private methods instead klass = self.active_scaffold_config.model - klass.define_attribute_methods unless klass.attribute_methods_generated? + klass.define_attribute_methods # unless klass.attribute_methods_generated? # include the rest of the code into the controller: the action core and the included actions module_eval do include ActiveScaffold::Finder From 5fffd759842437f3a9b2cb94cf541fe6a45cbea4 Mon Sep 17 00:00:00 2001 From: Will Leonard Date: Thu, 27 Apr 2023 13:47:04 -0400 Subject: [PATCH 06/11] Update it this way --- lib/active_scaffold/extensions/name_option_for_datetime.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/active_scaffold/extensions/name_option_for_datetime.rb b/lib/active_scaffold/extensions/name_option_for_datetime.rb index 59e5edfcda..ddb264f9b7 100644 --- a/lib/active_scaffold/extensions/name_option_for_datetime.rb +++ b/lib/active_scaffold/extensions/name_option_for_datetime.rb @@ -16,5 +16,5 @@ def datetime_selector_with_name(options, html_options) end end -klass = defined?(ActionView::Helpers::InstanceTag) ? ActionView::Helpers::InstanceTag : ActionView::Helpers::Tags::DateSelect -klass.include(ActiveScaffold::Extensions::NameOptionForDatetime) +# klass = defined?(ActionView::Helpers::InstanceTag) ? ActionView::Helpers::InstanceTag : ActionView::Helpers::Tags::DateSelect +ActionView::Helpers::Tags::DateSelect.include(ActiveScaffold::Extensions::NameOptionForDatetime) From 981be28ef2f381c2d2319cd50f281a0d7f6bc7c8 Mon Sep 17 00:00:00 2001 From: Will Leonard Date: Mon, 8 May 2023 06:51:26 -0400 Subject: [PATCH 07/11] Fix this for rails 4 --- lib/active_scaffold/extensions/unsaved_associated.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/active_scaffold/extensions/unsaved_associated.rb b/lib/active_scaffold/extensions/unsaved_associated.rb index 2ae2523395..1307fee762 100644 --- a/lib/active_scaffold/extensions/unsaved_associated.rb +++ b/lib/active_scaffold/extensions/unsaved_associated.rb @@ -47,15 +47,15 @@ def associations_for_update # returns false if any yield returns false. # returns true otherwise, even when none of the associations have been instantiated. build wrapper methods accordingly. def with_unsaved_associated - associations_for_update.all? do |association| - association_proxy = send(association.name) - if association_proxy - records = association_proxy + associations_for_update.map do |association| + association_proxy = self.association(association.name) + if association_proxy&.target&.present? + records = association_proxy.target records = [records] unless records.is_a? Array # convert singular associations into collections for ease of use records.select {|r| r.unsaved? and not r.readonly?}.all? {|r| yield r} # must use select instead of find_all, which Rails overrides on association proxies for db access else true end - end + end.all? end end From 14be06a4ee9e8e9e527a231f5e9ed0f363f67772 Mon Sep 17 00:00:00 2001 From: Will Leonard Date: Fri, 15 Sep 2023 07:17:25 -0400 Subject: [PATCH 08/11] Stop logging this warning --- lib/active_scaffold/helpers/association_helpers.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/active_scaffold/helpers/association_helpers.rb b/lib/active_scaffold/helpers/association_helpers.rb index d2e6c5d0e5..ba90911f06 100644 --- a/lib/active_scaffold/helpers/association_helpers.rb +++ b/lib/active_scaffold/helpers/association_helpers.rb @@ -32,7 +32,7 @@ def association_options_count(association, conditions = nil) # returns options for the given association as a collection of [id, label] pairs intended for the +options_for_select+ helper. def options_for_association(association, include_all = false) - ActiveSupport::Deprecation.warn "options_for_association should not be used, use association_options_find directly" + # ActiveSupport::Deprecation.warn "options_for_association should not be used, use association_options_find directly" available_records = association_options_find(association, include_all ? nil : options_for_association_conditions(association)) available_records ||= [] available_records.sort{|a,b| a.to_label <=> b.to_label}.collect { |model| [ model.to_label, model.id ] } From 3d3804781c8a762838fb04988a2108444ead338c Mon Sep 17 00:00:00 2001 From: Will Leonard Date: Mon, 8 Jul 2024 08:53:52 -0400 Subject: [PATCH 09/11] CP https://github.com/activescaffold/active_scaffold/commit/5be134c35bd48bc0233537d3616096fb8d27e40d --- lib/active_scaffold/actions/core.rb | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/active_scaffold/actions/core.rb b/lib/active_scaffold/actions/core.rb index fb3ff7dd47..331ad259f6 100644 --- a/lib/active_scaffold/actions/core.rb +++ b/lib/active_scaffold/actions/core.rb @@ -70,11 +70,7 @@ def authorized_for?(options = {}) end def clear_flashes - if request.xhr? - flash.keys.each do |flash_key| - flash[flash_key] = nil - end - end + flash.clear if request.xhr? end def each_marked_record(&block) From 178c2393cece4d19148f3dfe23a8ea50c57d6383 Mon Sep 17 00:00:00 2001 From: Will Leonard Date: Fri, 6 Sep 2024 08:06:40 -0400 Subject: [PATCH 10/11] Backport some rails 4 activescaffold fixes https://github.com/activescaffold/active_scaffold/commit/e9faeace936ec9f3f74cd9658098d96cc22e9faa --- app/views/active_scaffold_overrides/_form_association.html.erb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/views/active_scaffold_overrides/_form_association.html.erb b/app/views/active_scaffold_overrides/_form_association.html.erb index ab48385f44..a551f3ae77 100644 --- a/app/views/active_scaffold_overrides/_form_association.html.erb +++ b/app/views/active_scaffold_overrides/_form_association.html.erb @@ -1,7 +1,6 @@ <% parent_record = @record associated = column.singular_association? ? [parent_record.send(column.name)].compact : parent_record.send(column.name).to_a -associated = associated.sort_by {|r| r.new_record? ? 99999999999 : r.id} unless column.association.options.has_key?(:order) if show_blank_record = column.show_blank_record?(associated) associated << build_associated(column, parent_record) end From dca6b752c51077bb0d10dafc3a847bd766af2dbc Mon Sep 17 00:00:00 2001 From: Will Leonard Date: Tue, 12 Nov 2024 12:00:52 -0500 Subject: [PATCH 11/11] Fix this for rails 4.1 Based on https://github.com/activescaffold/active_scaffold/commit/f9c495d1a435a7aa9d3ca01c4edfc4eed69e6300 And still this way https://github.com/activescaffold/active_scaffold/blob/master/lib/active_scaffold/helpers/association_helpers.rb#L48 --- lib/active_scaffold/helpers/association_helpers.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/active_scaffold/helpers/association_helpers.rb b/lib/active_scaffold/helpers/association_helpers.rb index ba90911f06..03d4a39606 100644 --- a/lib/active_scaffold/helpers/association_helpers.rb +++ b/lib/active_scaffold/helpers/association_helpers.rb @@ -18,7 +18,7 @@ def association_options_find(association, conditions = nil, klass = nil) relation = klass.where(conditions).where(association.options[:conditions]) relation = relation.includes(association.options[:include]) if association.options[:include] relation = yield(relation) if block_given? - relation.all + relation.to_a end # Provides a way to honor the :conditions on an association while searching the association's klass