brick 1.0.225 → 1.0.227

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7f82da7422196469fc96ed7e6a720404547125622e4a9221b762d2797ddfa1a1
4
- data.tar.gz: 48db61484c3899a2ee44754979eca01442d1c396e2ae10df8c5bb707d45398fa
3
+ metadata.gz: 1640b4022f78ed3bba288342fd3cb4f3c90cdb75c09aa804b9aeb7e91ae64403
4
+ data.tar.gz: 1c44e055658540a923db08a4ef0114f1291024acb90c2cad26631c61a9b050a9
5
5
  SHA512:
6
- metadata.gz: 33e2eb178a7eb4e7c04ea47ee7cb14b732eb43918974ef189f7423615158acae66a6135ba43373cdc30fa6dffff83388e32f3f0610450f6ae46a66dd9e672176
7
- data.tar.gz: e7f04e018e0f21780c2d1a6705a5f39b3a62321d7314fb5b3f0924c77ca11344c5a1928231ac39b32daa858e3411cdee9eb8c09d55992677f46384f2e474cdba
6
+ metadata.gz: 61345c77cea2b0d61f9828086f3c9e9b464d377945b2a1a78822f4db36bd37a73e052689750b23f54549fd17e0cd5af0a794eec664ba3a593c4a5b90fb12be13
7
+ data.tar.gz: b05f1791d999a9e57ee1987a336dde5aefc1bfda029a8afd0a26103b4b64ea89bde3bad1f954f70fa25ec4d1d60aaf53ad7a363801c4695113b4ddbe6d52bf0b
@@ -459,7 +459,7 @@ module ActiveRecord
459
459
 
460
460
  # join_array will receive this relation name when calling #brick_parse_dsl
461
461
  _br_bt_descrip[bt.first] = if bt[1].is_a?(Array)
462
- # Last params here: "true" is for yes, we are polymorphic
462
+ # Last param here: "true" is for yes, we are polymorphic
463
463
  bt[1].each_with_object({}) { |bt_class, s| s[bt_class] = bt_class.brick_parse_dsl(join_array, bt.first, translations, true) }
464
464
  else
465
465
  { bt.last => bt[1].brick_parse_dsl(join_array, bt.first, translations) }
@@ -1497,7 +1497,7 @@ end
1497
1497
  # ... then just fall through and allow it to fail when trying to load the ____Controller class normally.
1498
1498
  end
1499
1499
  unless skip_controller
1500
- Object.send(:build_controller, self, class_name, plural_class_name, model, relations)
1500
+ Object.send(:build_controller, self, class_name, plural_class_name, model, relations, is_brick_prefix)
1501
1501
  end
1502
1502
 
1503
1503
  # MODULE
@@ -2096,7 +2096,7 @@ class Object
2096
2096
  end
2097
2097
  end
2098
2098
 
2099
- def build_controller(namespace, class_name, plural_class_name, model, relations)
2099
+ def build_controller(namespace, class_name, plural_class_name, model, relations, is_brick_prefix = nil)
2100
2100
  if (is_avo = (namespace.name == 'Avo' && Object.const_defined?('Avo')))
2101
2101
  # Basic Avo functionality is available via its own generic controller.
2102
2102
  # (More information on https://docs.avohq.io/3.0/controllers.html)
@@ -2278,8 +2278,12 @@ class Object
2278
2278
  end
2279
2279
 
2280
2280
  self.protect_from_forgery unless: -> { self.request.format.js? }
2281
- tn_start = (table_name_split = table_name.split('.')).length > 1 ? -2 : -1
2282
- plural_table_name = table_name_split[tn_start..-1].join('_').pluralize
2281
+ pcn_split = [plural_class_name]
2282
+ namespace_names = namespace&.name&.split('::')
2283
+ namespace_names&.shift if is_brick_prefix
2284
+ pcn_split.unshift(namespace_names.join('::')) if namespace_names.present?
2285
+ tn_start = pcn_split.length > 1 ? -2 : -1
2286
+ plural_table_name = pcn_split[tn_start..-1].join.underscore.pluralize
2283
2287
  singular_table_name = plural_table_name.singularize
2284
2288
  unless is_avo
2285
2289
  self.define_method :index do
@@ -681,7 +681,7 @@ window.addEventListener(\"popstate\", linkSchemas);
681
681
  rescue StandardError => e
682
682
  # Search through the routes to confirm that something might match (Devise stuff for instance, which has its own view templates),
683
683
  # and bubble the same exception (probably an ActionView::MissingTemplate) if a legitimate option is found.
684
- raise if ActionView.version >= ::Gem::Version.new('5.0') &&
684
+ raise if ActionView.version >= ::Gem::Version.new('5.0') && args[1] &&
685
685
  ::Rails.application.routes.set.find { |x| args[1].include?(x.defaults[:controller]) && args[0] == x.defaults[:action] }
686
686
 
687
687
  find_template_err = e
@@ -691,8 +691,8 @@ window.addEventListener(\"popstate\", linkSchemas);
691
691
 
692
692
  if @_brick_model
693
693
  pk = @_brick_model._brick_primary_key(::Brick.relations.fetch((table_name = @_brick_model.table_name.split('.').last), nil))
694
- rn_start = (res_name_split = model_name.split('::')).length > 1 ? -2 : -1
695
- obj_name = res_name_split[rn_start..-1].join('_').singularize
694
+ rn_start = (mn_split = model_name.split('::')).length > 1 ? -2 : -1
695
+ obj_name = mn_split[rn_start..-1].join.underscore.singularize
696
696
  res_name = obj_name.pluralize
697
697
 
698
698
  path_obj_name = @_brick_model._brick_index(:singular)
@@ -94,7 +94,17 @@ module Brick::Rails::FormTags
94
94
  # (After restarting the server it worked fine again.)
95
95
  row_count = 0
96
96
  # if @_brick_join_array&.include?()
97
- enumerator = relation.each # Runs the SQL query
97
+ begin
98
+ enumerator = relation.each # Runs the SQL query
99
+ rescue ActiveRecord::SubclassNotFound => e
100
+ # If there is a missing STI class then keep the show on the road by temporarily modifying the inheritance column.
101
+ inh_col = klass.inheritance_column
102
+ puts "WARNING: At least one row in the \"#{klass.table_name}\" table has an invalid value in the inheritance column \"#{inh_col}\"."
103
+ puts e.message
104
+ klass.inheritance_column = '^\/^' # Some impossible column name
105
+ enumerator = relation.each
106
+ klass.inheritance_column = inh_col
107
+ end
98
108
  # Add proxied info for @_brick_includes
99
109
  # proxy = relation.instance_variable_get(:@proxy) || relation.instance_variable_set(:@proxy, {})
100
110
  bi = relation.instance_variable_get(:@_brick_includes)
@@ -5,7 +5,7 @@ module Brick
5
5
  module VERSION
6
6
  MAJOR = 1
7
7
  MINOR = 0
8
- TINY = 225
8
+ TINY = 227
9
9
 
10
10
  # PRE is nil unless it's a pre-release (beta, RC, etc.)
11
11
  PRE = nil
data/lib/brick.rb CHANGED
@@ -251,7 +251,7 @@ module Brick
251
251
  if (pri_models = (model.respond_to?(poly_types_method = "#{a.name}_types") &&
252
252
  model.send(poly_types_method)
253
253
  ) ||
254
- (rel_poly_bt = relations[model.table_name][:fks].find { |_k, fk| fk[:assoc_name] == a.name.to_s } &&
254
+ ((rel_poly_bt = relations[model.table_name][:fks].find { |_k, fk| fk[:assoc_name] == a.name.to_s }) &&
255
255
  (rel_poly_bt[1][:polymorphic] || rel_poly_bt&.last&.fetch(:inverse_table, [])&.map { |table| table.singularize.camelize })
256
256
  )
257
257
  ).is_a?(Array)
@@ -63,8 +63,8 @@ module Brick
63
63
  else
64
64
  Object
65
65
  end
66
- controller_parts[controller_parts.length - 1] = (controller_name = "#{controller_parts.last}Controller")
67
- _built_controller, code = Object.send(:build_controller, namespace, controller_name, controller_name, controller_option.model, relations)
66
+ _built_controller, code = Object.send(:build_controller, namespace, (controller_name = "#{controller_parts.last}Controller"), controller_parts.last, controller_option.model, relations)
67
+ controller_parts[-1] = controller_name
68
68
  path = ['controllers']
69
69
  path.concat(controller_parts.map(&:underscore))
70
70
  dir = +"#{::Rails.root}/app"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brick
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.225
4
+ version: 1.0.227
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lorin Thwaits
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-01-08 00:00:00.000000000 Z
11
+ date: 2025-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord