Reputation: 5382
I'm currently reading Beginning Rails 3. I'm coming from PHP and trying to learn Ruby and Rails. I'm looking at a _form partial and I have a few questions. Specifically about the line:
<%= form_for(@article) do |f| %>
What is the purpose of having the @article object in there as well as what is the function of variable f?
thanks, mike
Upvotes: 1
Views: 247
Reputation: 160170
The @article
is what the form is for (in this case).
The f
is for creating individual form elements; it's a builder object yielded by form_for
's block.
Upvotes: 0
Reputation: 8101
form_for
accepts a model so that it can do a few things for you under the covers:
If you just want the tag helpers, there's also form_tag
and friends
Upvotes: 4