0
我已經實現了will_paginate,現在我想將默認頁面更改爲ruby變量的日期。我會怎麼做呢?Paginate上的自定義鏈接
要多一點精確:我的目標是有1個每頁日期和都屬於此日期此頁面
從視圖中摘錄的數據:
def show
@waves = @location.infos.paginate(page: params[:page], per_page: 7)
gon.watch.infos = @location.infos
respond_with(@location)
從片段控制器:
<table class= "table table-striped">
<thead>
<th><strong>Day</strong></th>
<th><strong>Swell Size</strong></th>
<th><strong>Swell Rating</strong></th>
<th><strong>Wind Speed</strong></th>
<th><strong>Temperature</strong></th>
</thead>
<tbody>
<!-- <%= will_paginate @waves, previous_label: "Previous day", next_label: "Next day", renderer: BootstrapPagination::Rails %> -->
<%= will_paginate(@waves, :renderer => PaginationListLinkRenderer) %>
<% @waves.each do |wave| %>
<tr>
<td><%= Time.at(wave.day.to_i).to_s.chomp("-0800")%></td>
<td><%= wave.size_min%>-<%= wave.size_max%><small>ft</small></td>
<td><% swell = wave.swell_rating %>
<td><%= wave.wind_speed%><small>mph</small></td>
<td><%= wave.temperature%><small>°F</small> </td>
感謝您的回覆。所以,我在記錄上創建了一個名爲day的屬性,這個屬性是我想要使用的unix時間戳。然而,我在哪裏創建sql查詢(鍵入什麼文件等)和分頁控制。你能提供一些示例代碼嗎? – 2014-11-21 20:28:31