How cat I get list of validations defined in model
Example:
class ModelName
validates_presence_of :field_name
validates_inclusion_of :sex, :in => %w(M F)
end
I need Hash like:
{:field_name => 'required', :sex => 'Must be in: M, F'}
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.
You don’t need a plugin for basic needs.
You can do this to get a hash of all validators.
If you want to get the validators for a specific field :