Could anyone point me to examples of a non-database-driven feedback
form, for instance, a simple e-mail feedback form that takes advantage
of ActionMailer? (How do I carry a POST through to a ‘def’ w/o a
database connection?)
Rails Recipe 64, “Validating Non-Active Record Objects,” in Chad
Fowler’s
“Rails Recipes” offers one solution. Another is to use an in-memory
SQLite
database as shown in the code below. Assuming the ClaimStatus model, you
can
then create a ClaimStatusController, and associated views just as though
you
were using a database.
private
def validate
unless attributes_before_type_cast[‘date_of_loss’] =~
/^(\d+(-|/)){2}\d{4}/
errors.add(‘date_of_loss’, ‘use the form: mm/dd/yyyy’)
end
end
end