Is it possible to use standard Rails validations with a Postgres array? I have a service_area column which accepts an array of zip codes. It works well enough, though when I try to use validations for numericality and length, the validators throw errors. Input such as 78702, 78704, 78705 gets the error messages is not a number and is the wrong length. It appears that Rails is trying to validate them as a string, rather than as an array of five digit zipcodes. Is there some way to inform the validator that it needs to parse the input as an array? Thanks!
Add a comment
|
1 Answer
Is there something stopping you from converting it to array explicitely like this?
"1, 2, 3".split(',').map(&:to_i)
2 Comments
nullnullnull
The question would be how'd I'd send that array to the validators instead of the string.
x3qt
Without viewing your code I can only recommend to try out postgres_ext gem.