Ask Your Question
3

What is the problem with the foreign key in the has_many :through association using STI in Ruby on Rails?

asked 2022-04-18 11:00:00 +0000

david gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-10-16 04:00:00 +0000

huitzilopochtli gravatar image

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-04-18 11:00:00 +0000

Seen: 9 times

Last updated: Oct 16 '21