开发者

error in sql query in the controller

When I do a find :all in the controller, my view shows the query resul开发者_Python百科t also. Which I dont want it to show. However when I am doing the same thing with params :id its not showing the query result. How do I not show the query result using find :all?

This is the part where I am rendering it. My videos/ _show.html.erb has the following code.

<table id="topics" style="border:1px solid black"> 
  <%= videos.each do |video|%> 
    <tr> 
      <td bgcolor="#ffffff" onclick=change(<%= video.video_time%>)>
        <%= video.topic%>
      </td> 
      <td>
        <%= video.video_time%>
      </td>
    </tr> 
  <% end %> 
</table> 

The view is:

[#<Video id: 1, video_url: "/RandyPausch.flv", topic: "Looks around", created_at: "2011-06-13 09:58:00", updated_at: "2011-06-13 09:58:00", timeline: "156.177", video_time: "156.177">] Looks around   156.177 as  0.133 kljdd 0.133


You need to make sure that you do not use the equal sign (=) when including embedded ruby for which you do not want to print results. Specifically, remove the = from the videos.each do |video| line, like so:

<table id="topics" style="border:1px solid black"> 
  <% videos.each do |video|%> 
    <tr> 
      <td bgcolor="#ffffff" onclick=change(<%= video.video_time%>)><%= video.topic%></td> 
      <td><%= video.video_time%> </td> 
    </tr> 
  <% end %> 
</table>


The problem is in the line:

<%= videos.each do |video| %>

There should not be the '=', so:

<% videos.each do |video| %>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜