I have a form with a fairly small number of parameters passed to the controller for processing. The various "sets" of parameters are called in the same way:
setname1_paramname
setname1_paramname2
Now I need to check one of these βsetsβ to make sure all fields are sent. Right now, I am doing this with an If or style statement:
if setname1_paramname.blank? || setname1_paramname2.blank? || ...etc
@object.errors.add_to_base("All setname1 fields are required.").
render :action => 'new'
return false
end
Is there a way to programmatically loop over these parameters and add them to @object errors?
Thank!
source
share