Skip to content

Commit 69ab184

Browse files
authored
Fix: use klass.table_name instead of guessing from associated models (#847)
Thanks!
1 parent 7863949 commit 69ab184

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

lib/annotate/annotate_models.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -846,9 +846,7 @@ def ignored_translation_table_colums(klass)
846846
# Construct the foreign column name in the translations table
847847
# eg. Model: Car, foreign column name: car_id
848848
foreign_column_name = [
849-
klass.translation_class.to_s
850-
.gsub('::Translation', '').gsub('::', '_')
851-
.downcase,
849+
klass.table_name.to_s.singularize,
852850
'_id'
853851
].join.to_sym
854852

spec/lib/annotate/annotate_models_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,8 +389,8 @@ def mock_column(name, type, options = {})
389389

390390
context 'with Globalize gem' do
391391
let :translation_klass do
392-
double('Post::Translation',
393-
to_s: 'Post::Translation',
392+
double('Folder::Post::Translation',
393+
to_s: 'Folder::Post::Translation',
394394
columns: [
395395
mock_column(:id, :integer, limit: 8),
396396
mock_column(:post_id, :integer, limit: 8),

0 commit comments

Comments
 (0)