On 3/8/07, Glenn Little <[EMAIL PROTECTED]> wrote:
My problem is that if I do the above and incorrectly fill out
the form, then the "render" line is called and fails because
"new_mail.rhtml" now has nil values for the vars that were
supposed to be set up in the new_meal action.

Probably the quickest, easiest approach right now is to use a private
helper method in your controller to initialize the meal object. "@meal
= initialize_meal" or somesuch, which you'd call in both the new_meal
and create_meal action. (Incidentally, I'd recommend looking into
RESTful naming conventions if you haven't already...)

A more "proper" approach "might" be to override the initialize method
of the meal object. Rails doesn't really let you do that, but hooks
like before_create can help get around that and might be a good
solution for you, depending on what you're setting and how.

Anyway, I'd start with the helper.

--
Nick Zadrozny • http://missionsbridge.org/people/nick
_______________________________________________
Sdruby mailing list
[email protected]
http://lists.sdruby.com/mailman/listinfo/sdruby

Reply via email to