# Passing variable in form

**URL:** <https://www.ruby-forum.com/t/passing-variable-in-form/145089>\
**Category:** Rails\
**Created:** [August 5, 2008, 10:17pm UTC](https://www.ruby-forum.com/t/passing-variable-in-form/145089 "2008-08-05T22:17:04Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![vapor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/5e9695/32.png) [@vapor](https://www.ruby-forum.com/u/vapor)\
**Post date:** [August 5, 2008, 10:17pm UTC](https://www.ruby-forum.com/t/passing-variable-in-form/145089/1 "2008-08-05T22:17:04Z")

</div>

I want to pass a variable task\_id to my todo form. How can I pass it  
without using hidden field?

---

<div class="post-metadata">

**Author:** ![vapor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/5e9695/32.png) [@vapor](https://www.ruby-forum.com/u/vapor)\
**Post date:** [August 5, 2008, 11:51pm UTC](https://www.ruby-forum.com/t/passing-variable-in-form/145089/2 "2008-08-05T23:51:53Z")

</div>

Vapor … wrote:

> I want to pass a variable task\_id to my todo form. How can I pass it  
> without using hidden field?

How are you passing it? If you create the object when you load the page  
then it is available to the page as it loads. For example, if in your  
controller method you say something like:

@task\_d= Tasks.find( :first, :conditions =\> [‘id = ?’, 12345])

Then you can always use that @task\_id object to populate a text field,  
for example:

" /\>

Can you give us some code so we can see what it is you are trying to do?

-S

---

<div class="post-metadata">

**Author:** ![vapor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/5e9695/32.png) [@vapor](https://www.ruby-forum.com/u/vapor)\
**Post date:** [August 6, 2008, 7:05am UTC](https://www.ruby-forum.com/t/passing-variable-in-form/145089/3 "2008-08-06T07:05:05Z")

</div>

Shandy N. wrote:

> How are you passing it? If you create the object when you load the page  
> then it is available to the page as it loads. For example, if in your  
> controller method you say something like:
> 
> @task\_d= Tasks.find( :first, :conditions =\> [‘id = ?’, 12345])

Actually I am trying to do has\_many relation without using REST, so I  
have to pass the value of parent (task\_id) through form.

---

<div class="post-metadata">

**Author:** ![vapor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/5e9695/32.png) [@vapor](https://www.ruby-forum.com/u/vapor)\
**Post date:** [August 6, 2008, 7:44am UTC](https://www.ruby-forum.com/t/passing-variable-in-form/145089/4 "2008-08-06T07:44:49Z")

</div>

You don’t want to use REST? Do you not want to use your mouth to eat  
too?

Using restful routes greatly assists you in stuff like this, please do  
use it, it’s there for a reason.

---

<div class="post-metadata">

**Author:** ![vapor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/5e9695/32.png) [@vapor](https://www.ruby-forum.com/u/vapor)\
**Post date:** [August 6, 2008, 7:51am UTC](https://www.ruby-forum.com/t/passing-variable-in-form/145089/5 "2008-08-06T07:51:50Z")

</div>

> > 
> 
> ## oh! you guys are arrogant. all right I am going to use REST!

Maaaaaaaaaam! He used the “a” word!

Believe me, once you use REST you’ll wonder how you lived without it.

---

<div class="post-metadata">

**Author:** ![vapor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/5e9695/32.png) [@vapor](https://www.ruby-forum.com/u/vapor)\
**Post date:** [August 6, 2008, 7:46am UTC](https://www.ruby-forum.com/t/passing-variable-in-form/145089/6 "2008-08-06T07:46:41Z")

</div>

Ryan B. wrote:

> You don’t want to use REST? Do you not want to use your mouth to eat  
> too?
> 
> Using restful routes greatly assists you in stuff like this, please do  
> use it, it’s there for a reason.

oh! you guys are arrogant.  
all right I am going to use REST!
