开发者

Display results

开发者 https://www.devze.com 2023-02-21 01:09 出处:网络
I posted earlier and this is an extenstion of my old question. I have a several users in my db and each will add their results.I need a way of taki开发者_运维问答ng each of these results and displayi

I posted earlier and this is an extenstion of my old question. I have a several users in my db and each will add their results. I need a way of taki开发者_运维问答ng each of these results and displaying them all (for all results from all users) into a table. I tried something like:

<% Result.find(:all) do |result| %>
  <%= result.name %>
<% end %>

where name is a field in the model Result and that did not display anything. Any ideas into how to do that. Much appreciated.


Hey, you missed each

<% Result.find(:all).each do |result| %>
  <%= result.name %>
<% end %>

or

<% Result.all.each do |result| %>
  <%= result.name %>
<% end %>

Update

<table>
  <tr>
    <% Result.all.each do |result| %>
      <td><%= result.name %></td>
    <% end %>
  </tr>
</table>


You have forget to call each

<% Result.all.each do |result| %>
  <%= result.name %>
<% end %>
0

精彩评论

暂无评论...
验证码 换一张
取 消