I am trying to implement server side validations, to do that i receive the form values in the variable @value
@value = {"prev_school":{"name":"","class":"Nursery"},"sibling": {"name":""}}
@validate = {"prev_school":[{"name":["is_mandatory","is_alphabets"]}}
In @variable I have defined the methods that need to be called for each field. My question is when I run the following code
@value.each do |key,val|
@validate.each do |k,v|
if k == key puts v end
end
end
I am getting an error pointing to the if statement
syntax error, unexpected tIDENTIFIER, expecting kDO or '{' or '('
Could somebody please help with this.
Cheers! 🙂
You want one of these:
or
Your version is a syntax error because Ruby doesn’t know that you mean to end the
ifbetweenkeyandputsso it is trying to interpretkey puts vas an argument for==but gets confused.