# Issue with FOR loop?

**URL:** <https://www.ruby-forum.com/t/issue-with-for-loop/125958>\
**Category:** Rails\
**Created:** [January 14, 2008, 7:07am UTC](https://www.ruby-forum.com/t/issue-with-for-loop/125958 "2008-01-14T07:07:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![venu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/9de0a6/32.png) [@venu](https://www.ruby-forum.com/u/venu)\
**Post date:** [January 14, 2008, 7:07am UTC](https://www.ruby-forum.com/t/issue-with-for-loop/125958/1 "2008-01-14T07:07:01Z")

</div>

My view rhtml contains the following

\<% for contactaddress in @contact\_address %\>  
\<%= text\_field “contactaddress”, “addr\_line1”, “size” =\> 50 %\>\</  
\<%end%\>

In the above code @contactact\_address contains several contact address  
objects. The for loop iterates each of them and tries to show the value  
of model attribute addr\_line1 in the text input box.

The problem

In the rhtml it creates a text input field but it doesn’t show value of  
addr\_line1 in the text input box.

What is wrong here? Thanks in advance for your help…

Regards  
Venu

---

<div class="post-metadata">

**Author:** ![venu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/9de0a6/32.png) [@venu](https://www.ruby-forum.com/u/venu)\
**Post date:** [January 14, 2008, 7:15am UTC](https://www.ruby-forum.com/t/issue-with-for-loop/125958/2 "2008-01-14T07:15:07Z")

</div>

Try doing \<% for @contactaddress in @contact\_addresses %\>

On Jan 14, 2008 4:37 PM, Venu Vallayil  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> ## of model attribute addr\_line1 in the text input box.
> 
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> >

–  
Ryan B.

> **[frozenplague.net](http://www.frozenplague.net)**
>
> This domain may be for sale!

Feel free to add me to MSN and/or GTalk as this email.

---

<div class="post-metadata">

**Author:** ![venu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/9de0a6/32.png) [@venu](https://www.ruby-forum.com/u/venu)\
**Post date:** [January 14, 2008, 7:21am UTC](https://www.ruby-forum.com/t/issue-with-for-loop/125958/3 "2008-01-14T07:21:15Z")

</div>

Ryan B. wrote:

> Try doing \<% for @contactaddress in @contact\_addresses %\>
> 
> On Jan 14, 2008 4:37 PM, Venu Vallayil  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> wrote:
> 
> > ## of model attribute addr\_line1 in the text input box.
> > 
> > Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> > 
> > >
> 
> –  
> Ryan B.  
> [http://www.frozenplague.net](http://www.frozenplague.net)  
> Feel free to add me to MSN and/or GTalk as this email.

Ryan…an instance variable won’t be allowed…I got error message  
saying this.

Thanks  
Venu

---

<div class="post-metadata">

**Author:** ![venu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/9de0a6/32.png) [@venu](https://www.ruby-forum.com/u/venu)\
**Post date:** [January 14, 2008, 8:06am UTC](https://www.ruby-forum.com/t/issue-with-for-loop/125958/4 "2008-01-14T08:06:35Z")

</div>

On 14 Jan 2008, at 06:07, Venu Vallayil wrote:

> value  
> of model attribute addr\_line1 in the text input box.

text\_field expects the first parameer to be the name of an instance  
variable.  
Either create an instance variable with that name, or use  
text\_field\_tag or look into fields\_for which allows you to escape that  
convention.

Fred
