From 3ef3252694704ef2a7a21eb4d6f3df2d189a1edd Mon Sep 17 00:00:00 2001 From: Matt Jones Date: Sun, 25 Sep 2011 17:24:55 -0400 Subject: [PATCH] [#915] ignore generated :polymorphic klass shims in migration generator --- .../hobo/extensions/active_record/associations/reflection.rb | 2 +- hobo_fields/lib/generators/hobo/migration/migrator.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hobo/lib/hobo/extensions/active_record/associations/reflection.rb b/hobo/lib/hobo/extensions/active_record/associations/reflection.rb index 4254af73c..d8fe0d0b6 100644 --- a/hobo/lib/hobo/extensions/active_record/associations/reflection.rb +++ b/hobo/lib/hobo/extensions/active_record/associations/reflection.rb @@ -9,7 +9,7 @@ def klass_with_create_polymorphic_class begin klass_without_create_polymorphic_class rescue NameError => e - Object.class_eval "class #{e.missing_name} < ActiveRecord::Base; set_table_name '#{active_record.name.tableize}'; end" + Object.class_eval "class #{e.missing_name} < ActiveRecord::Base; set_table_name '#{active_record.name.tableize}'; def self.hobo_shim?; true; end; end" e.missing_name.constantize end else diff --git a/hobo_fields/lib/generators/hobo/migration/migrator.rb b/hobo_fields/lib/generators/hobo/migration/migrator.rb index fa0cfe23c..37173b311 100644 --- a/hobo_fields/lib/generators/hobo/migration/migrator.rb +++ b/hobo_fields/lib/generators/hobo/migration/migrator.rb @@ -130,7 +130,7 @@ def models_and_tables all_models = table_model_classes hobo_models = all_models.select { |m| m.try.include_in_migration && m.name.underscore.not_in?(ignore_model_names) } non_hobo_models = all_models - hobo_models - db_tables = connection.tables - Migrator.ignore_tables.*.to_s - non_hobo_models.*.table_name + db_tables = connection.tables - Migrator.ignore_tables.*.to_s - non_hobo_models.reject { |t| t.try.hobo_shim? }.*.table_name [hobo_models, db_tables] end