Forum: Ruby on Rails My form_for example works correctly, but *WHY* does it work?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Bc298d7a9345ed1f83b39afe288f5e9e?d=identicon&s=25 rob (Guest)
on 2007-07-01 04:35
(Received via mailing list)

I am still new to Rails and have been trying to understand forms and
form_for, but it seems there are a number of ways to do / specify
things that all work fine. For example, I created this simple example
that works exactly how it should:

My questions are:

- I see many people do <% form_for :category, @category ... %>,
whereas I did just <% form_for :category .. %>. Someone said this
would be so the @category instance variable would be available to
prepopulate the form on validation, but my example successfully
prepopulates the form just fine on validation without the addition of
@category. Why?

- Doing :object => f causes us to use the 'form' object when
specifying methods like form.text_field. Where did 'form' come from? I
noticed I can achieve the same thing doing :locals => { :f => f } and
then using f.text_field in the helper.

Thanks for the help in understanding this.
D7c511ce5025d37b8c6bd9134e0f2bd9?d=identicon&s=25 Thorsten (Guest)
on 2007-07-01 11:15
(Received via mailing list)
Some Browsers (e.g. FF) Save form data when you go back&forth in
browser history. Taht may be it. Test it in IE and i my guess is that
it won't work there ;)

rob schrieb:
This topic is locked and can not be replied to.