- ruby
- rails
Rails enum with _prefix: true avoids method name collisions
When two models both define a status enum, the generated scope methods like .active or .archived can collide or cause confusion across models.
Adding _prefix: true scopes the generated methods to the enum name:
enum :status, { active: 0, archived: 1 }, _prefix: true
This generates order_active, order_archived scopes instead of just active / archived, making intent clear and avoiding conflicts.