Trying to make HTML table using Ecto query

Hi, i’m trying to make a table on my website out of a simple ecto query that passes 3 fields -> id, name and cpf.

query = from r in School.Responsible, 
select: [r.id,r.name,r.cpf], 
responsible = School.Repo.all(query) 
render(conn, “new.html”,responsible: responsible)

However i’m still fairly new in this, and when i use this

<%=@responsible=>

it gives me the list but i can’t find how to separate it by rows like:
-> id1 name2 cpf2
->id2 name2 cpf2…

appreciate any help! thanks!

You will need to iterate over the results

<table>
  <%= for row <- @responsible do %>
    <tr>
      <%= for field <- row do %>
        <td><%= field %></td>
      <% end %>
    </tr>
  <% end %>
</table>
3 Likes

It worked perfectly, I hadn’t thought of it. Thanks!