Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is opened just to describe the issue with enums and forms;
If we follow official documentation or repos showcase page we have
form.combobox :rating, Movie.ratings
This style will work only if enum key and value are same (string) for example:
If we use default rails enum approach where enum value is stored as an integer inside the db column, this will not work, Rails will fail to set the enum value and raise an exception:
ArgumentError: '3' is not a valid rating
I've added te system test just to confirm this issue.
In order to make this work for default enum approach we would need to use
#keys
on the enum to pass the enum keys,like this
I don't think this is engines fault, but maybe(just maybe) this needs to be documented, or at least we should change examples in the showcase page to show the valid state;
This
<%= form.combobox :rating, Movie.ratings.keys %>
instead of this
<%= form.combobox :rating, Movie.ratings %>