Skip to content

Commit e5732b1

Browse files
author
Carlos Silva
committed
Fix for Rails 6.0
1 parent 08fddd9 commit e5732b1

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

spec/tests/belongs_to_many_spec.rb

+4-1
Original file line numberDiff line numberDiff line change
@@ -404,9 +404,12 @@
404404
connection.create_table(:players, id: :uuid) { |t| t.string :name }
405405
connection.create_table(:games, id: :uuid) { |t| t.uuid :player_ids, array: true }
406406

407+
options = { anonymous_class: player, foreign_key: :player_ids }
408+
options[:inverse_of] = false if Torque::PostgreSQL::AR610
409+
407410
game.table_name = 'games'
408411
player.table_name = 'players'
409-
game.belongs_to_many :players, anonymous_class: player, inverse_of: false
412+
game.belongs_to_many :players, **options
410413
end
411414

412415
subject { game.create }

spec/tests/has_many_spec.rb

+4-2
Original file line numberDiff line numberDiff line change
@@ -422,10 +422,12 @@
422422
connection.create_table(:players, id: :uuid) { |t| t.string :name }
423423
connection.create_table(:games, id: :uuid) { |t| t.uuid :player_ids, array: true }
424424

425+
options = { anonymous_class: game, foreign_key: :player_ids }
426+
options[:inverse_of] = false if Torque::PostgreSQL::AR610
427+
425428
game.table_name = 'games'
426429
player.table_name = 'players'
427-
player.has_many :games, array: true, anonymous_class: game,
428-
inverse_of: false, foreign_key: :player_ids
430+
player.has_many :games, array: true, **options
429431
end
430432

431433
subject { player.create }

0 commit comments

Comments
 (0)