Hi I want to validate a form input so it only takes the numbers 1-9 as input, how can this be achieved
I have this in my model but just cant seem to get the matching correct
validates_format_of :myfield, :with => ??????, :on => :create
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Please take a look here: http://apidock.com/rails/ActiveModel/Validations/HelperMethods/validates_inclusion_of
or
EDIT – I thought
myfieldwas aninteger, but if you have defined it asstringyou need to add thevalidates_numericality_of: