Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are polymorphic associations not supported by inverse_of?

From Rails Guide:

There are a few limitations to inverse_of support:

  • They do not work with :through associations.
  • They do not work with polymorphic associations.
  • They do not work with :as associations.
  • For belongs_to associations, has_many inverse associations are ignored.
like image 653
Favourite Onwuemene Avatar asked Jan 30 '16 17:01

Favourite Onwuemene


1 Answers

This is no longer true. The inverse_of is supported by through, polymorphic and belongs_to and has_many associations. The automatic detection however is not supported for through and associations which define foreign_key.

https://guides.rubyonrails.org/association_basics.html#bi-directional-associations

like image 113
dft Avatar answered Oct 13 '22 00:10

dft