# Simple View Template Question

**URL:** <https://www.ruby-forum.com/t/simple-view-template-question/192425>\
**Category:** Rails\
**Created:** [July 30, 2010, 2:40am UTC](https://www.ruby-forum.com/t/simple-view-template-question/192425 "2010-07-30T02:40:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![esjd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/9d8465/32.png) [@esjd](https://www.ruby-forum.com/u/esjd)\
**Post date:** [July 30, 2010, 2:40am UTC](https://www.ruby-forum.com/t/simple-view-template-question/192425/1 "2010-07-30T02:40:05Z")

</div>

I’m trying to render a list of div’s with ids “item1”, “item2”, “item3”,  
etc…  
Trying to do it like this:

\<% for i in removed\_email\_address@domain.invalid %\>

.. blah blah ..

\<% end %\>

Pretty sure the syntax is wrong. I couldn’t find the answer after  
googling for a bit - perhaps I’m too new and dont know where to look.

Help please?

---

<div class="post-metadata">

**Author:** ![esjd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/9d8465/32.png) [@esjd](https://www.ruby-forum.com/u/esjd)\
**Post date:** [July 30, 2010, 4:49am UTC](https://www.ruby-forum.com/t/simple-view-template-question/192425/2 "2010-07-30T04:49:34Z")

</div>

\<% @items.each do |item| %\>

  
\<%= item.record-name %\>

 \<% end %\>

I think it goes model.method action |table| tuple.relvar.  
I took the logic from here

> **[rails.info](http://guides.rails.info/getting_started.html#rest)**
>
> Ruby on Rails,Rails Tutorial,Ruby Basics,Rails 4,Bar Rails,Rail

[http://guides.rails.info/getting\_started.html#rest](http://guides.rails.info/getting_started.html#rest)and applied the  
solution  
for post to your problem.

I’m a newbian refuge as well.

---

<div class="post-metadata">

**Author:** ![esjd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/9d8465/32.png) [@esjd](https://www.ruby-forum.com/u/esjd)\
**Post date:** [July 30, 2010, 10:02am UTC](https://www.ruby-forum.com/t/simple-view-template-question/192425/3 "2010-07-30T10:02:43Z")

</div>

On 30 July 2010 01:40, Eddie Du [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> \<% end %\>
> 
> Pretty sure the syntax is wrong. I couldn’t find the answer after  
> googling for a bit - perhaps I’m too new and dont know where to look.

What is the problem that you see?

Colin

---

<div class="post-metadata">

**Author:** ![esjd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/9d8465/32.png) [@esjd](https://www.ruby-forum.com/u/esjd)\
**Post date:** [July 30, 2010, 10:26am UTC](https://www.ruby-forum.com/t/simple-view-template-question/192425/4 "2010-07-30T10:26:43Z")

</div>

On 30 July 2010 03:48, Angel Robert M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> \<% @items.each do |item| %\>
> 
>   
> \<%= item.record-name %\>
> 
> \<% end %\>

> > I’m trying to render a list of div’s with ids “item1”, “item2”, “item3”,

If you’re specifically after “item1” rather than “item\<item.id\>”, then  
you can use “each\_with\_index”:

\<% @items.each\_with\_index do |item, index| %\>

 \<%= item.record-name %\> 
\<% end %\>

---

<div class="post-metadata">

**Author:** ![esjd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/9d8465/32.png) [@esjd](https://www.ruby-forum.com/u/esjd)\
**Post date:** [July 30, 2010, 5:16pm UTC](https://www.ruby-forum.com/t/simple-view-template-question/192425/5 "2010-07-30T17:16:39Z")

</div>

I realized I just typed the quotes wrong. Sorry!  
Though thanks for the replies, especially @angel and @Michael P.,  
those are really helpful suggestions. 🙂
