Rails 4.1+ automatically detects the :inverse_of an association

Posted . Visible to the public.

Starting from 4.1, Rails automatically detects the inverse of an association, based on heuristics. Unfortunately, it does not seem to notify you when it fails to infer the :inverse_of, so you are better off to always manually set :inverse_of anyway.

Note that automatic inverse detection only works on has_many, has_one, belongs_to associations. Extra options on the associations will prevent the association's inverse from being found automatically.

Sources

Dominik Schöler
Last edit
Besprechungs-PC
License
Source code in this card is licensed under the MIT License.
Posted by Dominik Schöler to makandra dev (2015-06-02 09:31)