Rails polymorphic has_many :through
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm pulling some data from an external API and would like to cache the results locally. I have a class SearchTerm , which I would like to be associated with a few different ActiveRecord types through the table searchable_items . I'm pretty sure I have the tables set up correctly, but something in my associations must be wrong. class Foo :searchable, :through => :searchable_items end class Bar :searchable, :through => :searchable_items end class SearchTerm :searchable_items end class SearchableItem true end I would expect to be able to do