Hello,
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:
http://pastie.caboo.se/75110
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.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Thorsten
2007-Jul-01 09:13 UTC
Re: My form_for example works correctly, but *WHY* does it work?
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:> Hello, > > 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: > > http://pastie.caboo.se/75110 > > 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.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---