Skip to content

Files

Latest commit

 

History

History
23 lines (14 loc) · 561 Bytes

Rails-EnumHash.md

File metadata and controls

23 lines (14 loc) · 561 Bytes

Pattern: Use of enum with array syntax

Issue: -

Description

Looks for enums written with array syntax.

When using array syntax, adding an element in a position other than the last causes all previous definitions to shift. Explicitly specifying the value for each key prevents this from happening.

Examples

# bad
enum status: [:active, :archived]

# good
enum status: { active: 0, archived: 1 }

Further Reading