Latest changes in Rails 7 introduces new syntax for defining an enum.
The previous syntax includes the key value pair for the enum name, its enum values, and the options.
The new syntax has made the enum name and the values a separate argument and the enum options can be passed as key value pairs.
These changes also work with the hash syntax.
The following instance methods will be generated by rails as usual and there are no changes here:
The following scopes will also be created
Note that the scopes for
status won’t be created as we have provided
Notice the changes in the option keys:
|Old Option||New Option|
Note: The previous syntax will keep working until it is deprecated.