brick 1.0.88 → 1.0.89

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: 9e346878b216d9e54ee0ca15be13ec0c2348f8cdf81d14a1eb4bc24ccb07aadb
4
- data.tar.gz: 92b54e7227fad318508104690158b5c756cc37171e7eeaaaba41d7da97c5518f
3
+ metadata.gz: a94d71d50a84c847db5f2c34e5aba600502ecb60d4dc7752dc65ac21f4ffe41b
4
+ data.tar.gz: 6f337f6220cf5989669497e85da0d4620861b1be6e4a35720a072698d866ebe2
5
5
  SHA512:
6
- metadata.gz: a8797a5e8924e3a89fd958f05d1bd442cf457428257cd697e438e1e6fe93427bc035177cea79fad47c6484427b30d2e3dc778f7a2166bc0fe27d383ce8659c1c
7
- data.tar.gz: 0bd6d3cc1ad92a1ec897b1524fde2e3f6849c783705312908d206460f9060677c93c295f3f3b89ddd514e2b3d5faeae4900472b0f4a1419e57e91046a190b3f7
6
+ metadata.gz: 703fa83ad63f9da5f4431c05db9fee57843419b62283f92f39b7b4cf9397848177f10f57af7fc03f08cf503a392676adac272a04fe4ae6becbf0e0a5eb62c550
7
+ data.tar.gz: 686c752bd2ed92de4f12c4afe27389d8a6cced25b47c5a18564c5afdf51199bd148f66ec5636ee8094a0cda5ae1ccafce31bc532a9d7d6a64c4cc968013f6af3
@@ -1201,7 +1201,8 @@ end
1201
1201
  <% end %>
1202
1202
 
1203
1203
  #{unless args.first == 'new'
1204
- confirm_are_you_sure = ActionView.version < ::Gem::Version.new('7.0') ? "data: { confirm: 'Delete #{model_name} -- Are you sure?' }" : "form: { data: { turbo_confirm: 'Delete #{model_name} -- Are you sure?' } }"
1204
+ # Was: confirm_are_you_sure = ActionView.version < ::Gem::Version.new('7.0') ? "data: { confirm: 'Delete #{model_name} -- Are you sure?' }" : "form: { data: { turbo_confirm: 'Delete #{model_name} -- Are you sure?' } }"
1205
+ confirm_are_you_sure = "data: { confirm: 'Delete #{model_name} -- Are you sure?' }"
1205
1206
  hms_headers.each_with_object(+'') do |hm, s|
1206
1207
  # %%% Would be able to remove this when multiple foreign keys to same destination becomes bulletproof
1207
1208
  next if hm.first.options[:through] && !hm.first.through_reflection
@@ -1212,7 +1213,14 @@ end
1212
1213
  s << "<table id=\"#{hm_name}\" class=\"shadow\">
1213
1214
  <tr><th>#{hm[3]}</th></tr>
1214
1215
  <% collection = @#{obj_name}.#{hm_name}
1215
- collection = collection.is_a?(ActiveRecord::Associations::CollectionProxy) ? collection.order(#{pk.inspect}) : collection.to_a.compact
1216
+ collection = case collection
1217
+ when ActiveRecord::Associations::CollectionProxy
1218
+ collection.order(#{pk.inspect})
1219
+ when ActiveRecord::Base # Object from a has_one
1220
+ [collection]
1221
+ else # We get an array back when AR < 4.2
1222
+ collection.to_a.compact
1223
+ end
1216
1224
  if collection.empty? %>
1217
1225
  <tr><td>(none)</td></tr>
1218
1226
  <% else %>
@@ -5,7 +5,7 @@ module Brick
5
5
  module VERSION
6
6
  MAJOR = 1
7
7
  MINOR = 0
8
- TINY = 88
8
+ TINY = 89
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
@@ -186,7 +186,7 @@ module Brick
186
186
 
187
187
  def get_bts_and_hms(model)
188
188
  bts, hms = model.reflect_on_all_associations.each_with_object([{}, {}]) do |a, s|
189
- next if !const_defined?(a.name.to_s.singularize.camelize) && ::Brick.config.exclude_tables.include?(a.plural_name)
189
+ next if !a.polymorphic? && (a.klass.nil? || ::Brick.config.exclude_tables.include?(a.klass.table_name))
190
190
 
191
191
  case a.macro
192
192
  when :belongs_to
@@ -194,7 +194,7 @@ module Brick
194
194
  rel_poly_bt = relations[model.table_name][:fks].find { |_k, fk| fk[:assoc_name] == a.name.to_s }
195
195
  if (primary_tables = rel_poly_bt&.last&.fetch(:inverse_table, [])).is_a?(Array)
196
196
  models = primary_tables&.map { |table| table.singularize.camelize.constantize }
197
- s.first[a.foreign_key] = [a.name, models, true]
197
+ s.first[a.foreign_key.to_s] = [a.name, models, true]
198
198
  else
199
199
  # This will come up when using Devise invitable when invited_by_class_name is not
200
200
  # specified because in that circumstance it adds a polymorphic :invited_by association,
@@ -203,7 +203,7 @@ module Brick
203
203
  puts " belongs_to :#{a.name}, polymorphic: true"
204
204
  end
205
205
  else
206
- s.first[a.foreign_key] = [a.name, a.klass]
206
+ s.first[a.foreign_key.to_s] = [a.name, a.klass]
207
207
  end
208
208
  when :has_many, :has_one # This gets has_many as well as has_many :through
209
209
  # %%% weed out ones that don't have an available model to reference
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.88
4
+ version: 1.0.89
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lorin Thwaits
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-02 00:00:00.000000000 Z
11
+ date: 2022-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord