Skip to content

Commit 1d6943d

Browse files
committed
Fix: use klass.table_name instead of guessing from associated models
1 parent 70aba78 commit 1d6943d

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
@@ -847,9 +847,7 @@ def ignored_translation_table_colums(klass)
847847
# Construct the foreign column name in the translations table
848848
# eg. Model: Car, foreign column name: car_id
849849
foreign_column_name = [
850-
klass.translation_class.to_s
851-
.gsub('::Translation', '').gsub('::', '_')
852-
.downcase,
850+
klass.table_name.to_s.singularize,
853851
'_id'
854852
].join.to_sym
855853

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)