I'm busy going through the guide on http://guides.rubyon...ng_started.html - I'm a bit stuck at the form builder part; I don't understand the following code:
<%= form_for :post do |f| %> <p> <%= f.label :title %><br> <%= f.text_field :title %> </p> <p> <%= f.label :text %><br> <%= f.text_area :text %> </p> <p> <%= f.submit %> </p> <% end %>
- In the first line, is form_for a method which takes the symbol :post as a parameter? What appears to happen next is that we start a block (which is basically an anonymous function, right?) and f is what is returned by the form_for method; it is the actual form builder object which creates our form on the page? Why does form_for take :post as a parameter? If I change it, it only seems to change the text on the submit button.
- With all the f.label/f.text_field/f.submit line, why are symbols being put after them? Okay, maybe that was a bit obscure, what I mean is, for example, with "f.label :title" are we saying: "take the form builder object, call a method named label and give it the parameter :title, which is also a symbol for some reason."