active_scaffold 4.0.11 → 4.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of active_scaffold might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 54f2b257dfe96b6225d421aed169b5909fc38860f42e7fcbc2686cf85023ce01
4
- data.tar.gz: 8fdb80d250229b5548f81f4c86023cfd78c73e23c2fe7d6d02296d9188ace1f0
3
+ metadata.gz: eb3908fe52caa2dcc8698d6430befa7b2e71580df16dc97536b120f145126015
4
+ data.tar.gz: b53eff968492567216dad68a739cc17d63acfb945f2b24b7a59ae7364347323b
5
5
  SHA512:
6
- metadata.gz: 5ff4509249d50b3cf874ec89685a77fa7c9360a2e8bb48a97044a730433428592073e879d514be3361857ae765d99f1a7cae26eaa9a163bb99db384e3b906030
7
- data.tar.gz: ca005e86b98e2748d95fd0a773d3eb004652dcc3fa3da4cd9b016b570b82e734ff2dca5eaaad534c7eadbbc10e030c53f8c2e437db6e9cee32329e6c77d848c7
6
+ metadata.gz: c95576ddc492127de9a0f21afff8847a8660d9141e7ce255ab7654b5cb4881bab36f3d12c38f2c250f3c8526c97989daf3254758b7d8f1112371fbb4099dd096
7
+ data.tar.gz: e40187cbc740f4bc7af4910d0aab40d3969904b5bd5de3c976adfaba486bff70348a90da13b7377b2286a9628d1ad8cbde9fc183226b118d4fc39a4a339e7433
data/CHANGELOG.rdoc CHANGED
@@ -1,3 +1,5 @@
1
+ - Filter includes for the selected model in select form_ui when column is a polymorphic association, as includes for polymorphic association may be a hash with the polymorphic association as key and associations of different models in the value
2
+
1
3
  = 4.0.11
2
4
  - Fix refresh_link with update_columns
3
5
 
@@ -36,7 +36,7 @@ module ActiveScaffold
36
36
  relation = klass.where(conditions)
37
37
  column = column_for_association(association, record)
38
38
  if column&.includes
39
- include_assoc = column.includes.find { |assoc| assoc.is_a?(Hash) && assoc.include?(association.name) }
39
+ include_assoc = includes_for_association(column, klass)
40
40
  relation = relation.includes(include_assoc[association.name]) if include_assoc
41
41
  end
42
42
  if column&.sort && column.sort&.dig(:sql)
@@ -49,6 +49,24 @@ module ActiveScaffold
49
49
  end
50
50
  end
51
51
 
52
+ def includes_for_association(column, klass)
53
+ includes = column.includes.find { |assoc| assoc.is_a?(Hash) && assoc.include?(column.association.name) }
54
+ return unless includes
55
+
56
+ includes = includes[association.name]
57
+ if column.association.polymorphic?
58
+ includes = Array.wrap(includes).filter_map do |assoc|
59
+ if assoc.is_a?(Hash)
60
+ assoc.select { |key, _| klass.reflect_on_association(key) }.presence
61
+ elsif klass.reflect_on_association(assoc)
62
+ assoc
63
+ end
64
+ end
65
+ end
66
+
67
+ includes.presence
68
+ end
69
+
52
70
  def column_for_association(association, record)
53
71
  active_scaffold_config_for(record.class).columns[association.name]
54
72
  rescue StandardError => e
@@ -2,7 +2,7 @@ module ActiveScaffold
2
2
  module Version
3
3
  MAJOR = 4
4
4
  MINOR = 0
5
- PATCH = 11
5
+ PATCH = 12
6
6
  FIX = nil
7
7
 
8
8
  STRING = [MAJOR, MINOR, PATCH, FIX].compact.join('.')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_scaffold
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.11
4
+ version: 4.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Many, see README
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-06-05 00:00:00.000000000 Z
11
+ date: 2025-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails