Flowdock
method

can_find_inverse_of_automatically?

Importance_1
can_find_inverse_of_automatically?(reflection) private

Checks to see if the reflection doesn’t have any options that prevent us from being able to guess the inverse automatically. First, the inverse_of option cannot be set to false. Second, we must have has_many, has_one, belongs_to associations. Third, we must not have options such as :polymorphic or :foreign_key which prevent us from correctly guessing the inverse association.

Anything with a scope can additionally ruin our attempt at finding an inverse, so we exclude reflections with scopes.

Show source
Register or log in to add new notes.