You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[email protected] introduced a new Rails/InverseOf cop (enabled by default).
The cop requires all has_one/has_many <=> belongs_to associations where Rails can't automatically determine the inverse relationship (such as in the presence of a class_name: or foreign_key: attribute) to explicitly specify the inverse relationship using inverse_of:.
This caused a number of offences, and when trying to add the missing inverse_of: attributes, a number of problems were encountered (below), so this cop has been locally disabled for now.
If we can resolve these issues, the cop can be reenabled (preferred).
Issues:
Account model defines an optional self-referential related_account association as follows:
But as only some transaction types are categorisable (e.g. BasicTransaction, Subtransaction), adding inverse_of: :transaction_category can't work as there's no Transaction.transaction_category association.
This may require using polymorphic: true and as:, e.g.
[email protected]
introduced a newRails/InverseOf
cop (enabled by default).The cop requires all
has_one
/has_many
<=>belongs_to
associations where Rails can't automatically determine the inverse relationship (such as in the presence of aclass_name:
orforeign_key:
attribute) to explicitly specify the inverse relationship usinginverse_of:
.This caused a number of offences, and when trying to add the missing
inverse_of:
attributes, a number of problems were encountered (below), so this cop has been locally disabled for now.If we can resolve these issues, the cop can be reenabled (preferred).
Issues:
Account
model defines an optional self-referentialrelated_account
association as follows:There is no inverse
has_one
association defined, so it is currently unclear if there should be one.Category
model has a parent/child association as follows:Adding
inverse_of: :children
andinverse_of: :parent
(respectively) caused aStack level too deep
error when trying to run the test suite.TransactionCategory
model has an association back to the baseTransaction
model as follows:But as only some transaction types are categorisable (e.g.
BasicTransaction
,Subtransaction
), addinginverse_of: :transaction_category
can't work as there's noTransaction.transaction_category
association.This may require using
polymorphic: true
andas:
, e.g.The text was updated successfully, but these errors were encountered: