Skip to content

Instantly share code, notes, and snippets.

@noniq
Created February 29, 2012 22:59
Show Gist options
  • Save noniq/1945188 to your computer and use it in GitHub Desktop.
Save noniq/1945188 to your computer and use it in GitHub Desktop.
def validate_inputs
self.form.descendants.any_in(:html_tag => ["input", "select", "textarea"]).excludes("html_attributes.type" => "submit").each do |element|
attr = "input_" + element.html_attributes["name"]
element.errors.add(:attr, " muss ausgefüllt werden") if element[attr].blank? && element["required"]
...
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment