Skip to content

Allow updates similar to Rails enums #58

@mthurman

Description

@mthurman

I swapped out some enums I was using for some flags. Especially in tests where I had to set up specific models, I was changing code like this: model.update(enum_field: :enum_value) to model.update(flags: [:flag1, :flag2]) which causes a null value to get sent to the db.

Instead, I ended up doing something like model.update(flags: 3) with a magic number.

It looks like it might be possible to do something similar to enums (https://github.com/rails/rails/blob/a9dc45459abcd9437085f4dd0aa3c9d0e64e062f/activerecord/lib/active_record/enum.rb#L165). Is there any interest in that?

Or any other recommendations to avoid magic numbers when setting multiple flags at once (without having to have one line of code per flag)?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions