# Form\_for question

**URL:** <https://www.ruby-forum.com/t/form-for-question/135218>\
**Category:** Rails\
**Created:** [April 19, 2008, 9:22am UTC](https://www.ruby-forum.com/t/form-for-question/135218 "2008-04-19T09:22:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![T\_K](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e0b2c6/32.png) [@T\_K](https://www.ruby-forum.com/u/T_K)\
**Post date:** [April 19, 2008, 9:22am UTC](https://www.ruby-forum.com/t/form-for-question/135218/1 "2008-04-19T09:22:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![T\_K](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e0b2c6/32.png) [@T\_K](https://www.ruby-forum.com/u/T_K)\
**Post date:** [April 19, 2008, 9:33am UTC](https://www.ruby-forum.com/t/form-for-question/135218/2 "2008-04-19T09:33:42Z")

</div>

: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](http://teapoci.blogspot.com)
