I’m reading the Ruby on Rails book by the pragmatic programmers, and it
has
a brief section on using the _tag input fields (text_field_tag, etc) to
collect form data for fields that don’t represent fields in a model.
They
do validation manually in the controller, which seems really clunky. Is
there any way to normalize the form validation between model input
fields
and non-model fields? It seems like a waste to have
validate_presense_of()
and then write a whole nother set of validation functions to validate
the
tag fields.
For example, say I have a log in page that just has two input fields,
neither of which correspond to an actual table or row because I call
some
other method to verify the login and password. Is there anyway that I
can
use all of the existing validation functionality to validate the form,
or is
the only way to manually check the validation in the controller? (and
subsquently, check for any error message in the view and display it)
It would be nice if there were a way to add validation rules to specific
elements without having to check each field in the controller.
I am very new to Ruby and Rails, so I may very well be missing something
obvious. I’ve asked in #rubyonrails and googled some though, without
finding
a very satisfactory explanation, so I’m hoping someone here may be able
to
help me. Thanks,
-Chris