Ask Your Question

Revision history [back]

The problem with the foreign key in the hasmany :through association using STI in Ruby on Rails is that it can cause ambiguity when there are multiple subclasses involved. Each subclass needs its own foreign key to its own specific table, but the hasmany :through association can only specify one foreign key. This can lead to errors or unexpected behavior when querying or manipulating the association. One potential solution is to use a polymorphic association instead of STI.