The Active Record Helper makes it easier to create forms for records kept
in instance variables. The most far-reaching is the form method that
creates a complete form for all the basic content types of the record (not
associations or aggregations, though). This is a great way of making the
record quickly available for editing, but likely to prove lackluster for a
complicated real-world form. In that case, it’s better to use the
input method and the specialized form methods in link:classes/ActionView/Helpers/FormHelper.html
| Public Methods |
| error_message_on |
Returns a string containing the error message attached to the
method on the object if one exists. This error message is
wrapped in a DIV tag, which can be extended to include a
prepend_text and/or append_text (to properly explain the
error), and a css_class to style it accordingly. object
should either be the name of an instance variable or the actual object. As
an example, let’s say you have a model post that has an
error message on the title attribute:
|
| error_messages_for |
Returns a string with a DIV containing all of the error messages
for the objects located as instance variables by the names given. If more
than one object is specified, the errors for the objects are displayed in
the order that the object names are provided.
|
| form |
Returns an entire form with all needed input tags for a specified Active
Record object. For example, let’s say you have a table model
Post with attributes named title of type VARCHAR
and body of type TEXT:
|
| input |
Returns a default input tag for the type of object returned by the method.
For example, let’s say you have a model that has an attribute
title of type VARCHAR column, and this instance holds "Hello
World":
|
<code/>and<pre/>for code samples.