Simple View Template Question

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 [email protected] %>

.. 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?

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


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

I think it goes model.method action |table| tuple.relvar.
I took the logic from here
http://guides.rails.info/getting_started.html#rest
http://guides.rails.info/getting_started.html#restand applied the
solution
for post to your problem.

I’m a newbian refuge as well.

On 30 July 2010 01:40, Eddie Du [email protected] 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

On 30 July 2010 03:48, Angel Robert M. [email protected]
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 %>

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs