# Form\_tag question

**URL:** <https://www.ruby-forum.com/t/form-tag-question/192189>\
**Category:** Rails\
**Created:** [July 26, 2010, 12:03am UTC](https://www.ruby-forum.com/t/form-tag-question/192189 "2010-07-26T00:03:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rcanand](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/6bbea6/32.png) [@rcanand](https://www.ruby-forum.com/u/rcanand)\
**Post date:** [July 26, 2010, 12:03am UTC](https://www.ruby-forum.com/t/form-tag-question/192189/1 "2010-07-26T00:03:34Z")

</div>

Hi,

I am somewhat new to rails, and I have a question about form\_tag:

I have the following :

\<%form\_tag “some\_action” do%\>  
…

and I have a route for

“posts/:id/some\_action”

When I run this, I notice that (what seems miraculously), the app fills  
in  
the id while calling this route like:

posts/12/some\_action

and even more surprisingly 12 is the id of the current post in my  
context.

My question is: without my specifying the id anywhere, how could rails  
know  
the id - is it reading my mind? Or maybe I am missing how form\_tag works  
(I  
assumed that it requires the id to be passed in explicitly to work).

Thanks  
Anand

---

<div class="post-metadata">

**Author:** ![rcanand](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/6bbea6/32.png) [@rcanand](https://www.ruby-forum.com/u/rcanand)\
**Post date:** [July 26, 2010, 12:07am UTC](https://www.ruby-forum.com/t/form-tag-question/192189/2 "2010-07-26T00:07:05Z")

</div>

On Jul 25, 11:01 pm, Anand R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> When I run this, I notice that (what seems miraculously), the app fills in  
> the id while calling this route like:
> 
> posts/12/some\_action
> 
> and even more surprisingly 12 is the id of the current post in my context.
> 
> My question is: without my specifying the id anywhere, how could rails know  
> the id - is it reading my mind? Or maybe I am missing how form\_tag works (I  
> assumed that it requires the id to be passed in explicitly to work).

Sounds like you’ve created a form whose action is a relative path - no  
rails magic here, just html.

Fred

---

<div class="post-metadata">

**Author:** ![rcanand](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/6bbea6/32.png) [@rcanand](https://www.ruby-forum.com/u/rcanand)\
**Post date:** [July 26, 2010, 1:49am UTC](https://www.ruby-forum.com/t/form-tag-question/192189/3 "2010-07-26T01:49:30Z")

</div>

Ah, ok - got it. Thanks!

On Sun, Jul 25, 2010 at 3:05 PM, Frederick C. \<
