我正在构建一个需要与单独数据库上的旧系统向后兼容的系统。我有这些课程:
Promotion
has_many :promotion_items
PromotionItem
belongs_to :promotion
belongs_to :item, polymorphic: true
Product
has_many :promotion_items, as: :item
Legacy::Product
establish_connection :legacy_db
has_many :promotion_items, as: :item
ActiveRecord正在尝试将Legacy::Product
表加入PromotionItem
,这显然不会跨数据库工作。有没有办法阻止ActiveRecord自动尝试加入并改为select * from products where id in [...]
?