From 37f334971936e1182544f6195aa3d327beef0626 Mon Sep 17 00:00:00 2001 From: oren Date: Fri, 15 Jan 2021 14:16:35 +0100 Subject: [PATCH] Fix: use klass.table_name instead of guessing from associated models --- lib/annotate/annotate_models.rb | 4 +--- spec/lib/annotate/annotate_models_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/annotate/annotate_models.rb b/lib/annotate/annotate_models.rb index ac214ffb4..cacf73cad 100644 --- a/lib/annotate/annotate_models.rb +++ b/lib/annotate/annotate_models.rb @@ -846,9 +846,7 @@ def ignored_translation_table_colums(klass) # Construct the foreign column name in the translations table # eg. Model: Car, foreign column name: car_id foreign_column_name = [ - klass.translation_class.to_s - .gsub('::Translation', '').gsub('::', '_') - .downcase, + klass.table_name.to_s.singularize, '_id' ].join.to_sym diff --git a/spec/lib/annotate/annotate_models_spec.rb b/spec/lib/annotate/annotate_models_spec.rb index 370298f3c..0cab5f55f 100644 --- a/spec/lib/annotate/annotate_models_spec.rb +++ b/spec/lib/annotate/annotate_models_spec.rb @@ -389,8 +389,8 @@ def mock_column(name, type, options = {}) context 'with Globalize gem' do let :translation_klass do - double('Post::Translation', - to_s: 'Post::Translation', + double('Folder::Post::Translation', + to_s: 'Folder::Post::Translation', columns: [ mock_column(:id, :integer, limit: 8), mock_column(:post_id, :integer, limit: 8),