我一直有很多麻煩與此生成表:紅寶石從日期範圍
對於RPI應用程序,我所有的結果是一個表中:結果
我想打印基於特定的數據範圍的表:2011-07-31..2012-07-01
在我的控制器:
class SeasonsController < ApplicationController
def s2012
@results = Result.all
@s2012 = Result.where(:date => (2011-07-31)..(2012-07-01))
end
end
在我看來:
<table>
<tr>
<th>Event ID</th>
<th>Date</th>
</tr>
<% @s2012.each do |result| %>
<tr>
<td><%= result.event_id %></td>
<td><%= result.date %></td>
</tr>
<% end %>
</table>
這不輸出任何錯誤(小奇蹟),但沒有顯示在視圖中。 @results = Result.all
打印所有整個表就好了。但是,我怎麼能限制它到一個特定的數據範圍?
這工作,謝謝!我現在感覺好多了。 我最初嘗試用SQL來解決這個問題,但是我無法獲得格式化權限,並且在花費時間花費時間將其開發爲活動記錄。 – Zigmister 2013-03-19 03:16:32