【发布时间】:2014-11-22 03:48:21
【问题描述】:
我已经实现了 will_paginate,现在我想将默认页面更改为来自 ruby 变量的日期。我该怎么做呢?
更准确地说:我的目标是每个日期有 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>
【问题讨论】:
标签: ruby-on-rails ruby pagination