You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create an ActiveRecord model with an enum, where the values are declared as array with an object:
enumstatus: [first: 10,second: 20]
(What happened here for us is that we accidentally used [] instead of {} when setting up the enum. It took longer to debug than it would have if this raised an error).
The error we got in our app was quite a few degrees removed from the actual issue. I'll see if I can cook up a simpler example project to demonstrate the issue.
The current error makes sense when seen in this simple case, but I'd argue that passing an array with an object is invalid input to enum, as the enum will be completely unusable.
Steps to reproduce
Create an ActiveRecord model with an enum, where the values are declared as array with an object:
(What happened here for us is that we accidentally used [] instead of {} when setting up the enum. It took longer to debug than it would have if this raised an error).
Demo project: https://github.com/thomassnielsen/enum-demo
Expected behavior
There should be some kind of error explaining that enums should not be an array of objects, rather an array of symbols or an object.
Actual behavior
No error was given, but enum did not work as expected.
System configuration
Rails version: 5.2.1
Ruby version: 2.5.1p57
The text was updated successfully, but these errors were encountered: