Skip to content

Commit 3bf07cb

Browse files
committed
Fix: use klass.table_name instead of guessing from associated models
1 parent d89ddef commit 3bf07cb

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
@@ -982,9 +982,7 @@ def ignored_translation_table_colums(klass)
982982
# Construct the foreign column name in the translations table
983983
# eg. Model: Car, foreign column name: car_id
984984
foreign_column_name = [
985-
klass.translation_class.to_s
986-
.gsub('::Translation', '').gsub('::', '_')
987-
.downcase,
985+
klass.table_name.to_s.singularize,
988986
'_id'
989987
].join.to_sym
990988

spec/lib/annotate/annotate_models_spec.rb

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

355355
context 'with Globalize gem' do
356356
let :translation_klass do
357-
double('Post::Translation',
358-
to_s: 'Post::Translation',
357+
double('Folder::Post::Translation',
358+
to_s: 'Folder::Post::Translation',
359359
columns: [
360360
mock_column(:id, :integer, limit: 8),
361361
mock_column(:post_id, :integer, limit: 8),

0 commit comments

Comments
 (0)