Form_for question

I have a following snippt to make a form.

<% form_for :post, @post, :url => { :action => “create” } do |f| -%>

<%- end ->

What does “:post” and “@post” do respectively?

If my understanding is correct, @post is there because I set “@post =
Post.new” in the action. But I don’t know what ":post " is for.

Tek

:post is the parameter that will be symbolic to f

another form format is

<% form_tag :action => “create” do %>

<%= text_field “post”, “name” %>
OR
<%= text_field :post, “name” %>

<% end %>
<% end_tag %>

BUT HERE

<% form_for :post, @post, :url => { :action => “create” } do |f| -%>

<%- end →

<%= f.text_field “name” %>

in your controller the input parameter will be
params[:posts] and its hash.
params[:posts][“name”]
params[:posts][“id”]

Like that.

reinhart
http://teapoci.blogspot.com