Skip to content

Latest commit

 

History

History
28 lines (19 loc) · 645 Bytes

Rails-DuplicateAssociation.md

File metadata and controls

28 lines (19 loc) · 645 Bytes

Pattern: Duplicate association

Issue: -

Description

This rule looks for associations that have been defined multiple times in the same file.

When an association is defined multiple times on a model, Active Record overrides the previously defined association with the new one. Because of this, this cop's autocorrection simply keeps the last of any duplicates and discards the rest.

Examples

# bad
belongs_to :foo
belongs_to :bar
has_one :foo

# good
belongs_to :bar
has_one :foo

Further Reading