0

My index action in my controller is something like this:

@dbs = somearray

My view corresponding to this action (index.html.erb) is trying to print only the elements of the @dbs array but it prints no only the elements individually but the entire array as well (which I want to avoid printing). The code printing in index.html.erb is:

<%= for db in @dbs do %>
  <tr>
    <td><%= db %></td>
  </tr>
<% end %>

This prints:

["ele1","ele2","ele3"]
----
ele1
----
ele2
----
ele3
----

How can I avoid printing: ["ele1","ele2","ele3"]? I just want to print the table with the elements!

1 Answer 1

4

The construction <%= %> is printing into output, <% %> doesn't print into output. Just change one line to this:

<% for db in @dbs do %>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.