Thursday, January 21, 2010

[Rails] Iterating through an Instance Variable in my View

I have an instance variable called @ls which is an array that contains a
list of files in a directory.

When I call this instance variable in my view like this:

<%= @ls %>

It shows the entire list of files in the array.

Since I need to edit what is displayed for each file name in the array,
I want to iterate through it in my view.

When I put this code in my view:
<% @ls.each do |a| %>
a.puts
<% end %>

... it only prints out the letter "a" as many times as the size of the
array.

Can anyone help me out with correcting this issue?

thanks

jackster
--
Posted via http://www.ruby-forum.com/.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate