0

I've got an array of symbols and I would like to use validate_inclusion_of to verify that a field in my model is one of those values in the array. The issue is that the field being compared is a string.

Obviously I could convert the array to store strings or pass a lambda to the in: argument which converts the symbols to strings at runtime, but I would rather be able to somehow perform to_sym on the field being compared before checking against the array. Is this possible?

Dan
  • 3,246
  • 1
  • 32
  • 52

1 Answers1

1

You should check out before_validation callback.
You can manipulate values before validation perform.

Ashutosh Tiwari
  • 984
  • 6
  • 16