I am using inclusion validation as
validates :field_type, :inclusion => %w(SA LA RB CB SB Date)
now when the validation is fired, I am getting "Field type is not included in the list"
. It is not making any sense to me. So, I want to have my own custom message saying "This value is not included in Field Type."
Can anyone guide me here?
Drivers can specify their own error types and error messages. To define a custom error message, you must first define a new IO_ERR_XXX value to specify as the ErrorCode member of the error log entry. The Event Viewer uses the IO_ERR_XXX value to look up the driver's error message.
Rails validation defines valid states for each of your Active Record model classes. They are used to ensure that only valid details are entered into your database. Rails make it easy to add validations to your model classes and allows you to create your own validation methods as well.
I think you want:
validates :field_type, :inclusion => { :in => %w(SA LA RB CB SB Date),
:message => "The value: %{value} is not included in Field Type." }
See this post.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With