RailsでEnumのマッピングエラーを簡単に解決する方法がない
Problem
What is defined as below:
enum state: { draft: 1, enabled: 2 disabled: 3 } If you put a wrong value which no defined in enum attribute, take a error ArgumentError: 'hoge' is not a valid status and wanna custom this error behavior such as error message.
Even if you’d like to modified code only a little, you couldn’t now.
How
I’m not sure, but it look like good. ActiveRecord::Enum validation in Rails API | by Kerollos Magdy | Nerd For Tech | Medium
You don’t have the way not to modified own code now.
References
This post is licensed under CC BY 4.0 by the author.