我遇到问题让will_paginate在这里工作。我已经尝试了几个关于控制器的不同建议但是仍然遇到了许多不同的错误。我这里的基本问题是如何修改下面的这段代码,以使我的“will_paginate”选项工作。我也使用bootstrap 3,并在下面发布了整个控制器和视图。感谢。
@pits = Pit.order('created_at DESC').group_by { |pit| pit.created_at.strftime("%B %Y") }
坑控制器
class PitsController < ApplicationController
def new
@pit = Pit.new
end
def index
@pit = Pit.all
@user = User.find_by(params[:id])
@pits = Pit.order('created_at DESC').group_by { |pit| pit.created_at.strftime("%B %Y") }
end
Pit index.html.erb
<div class = "container list-pits">
<%= link_to "Add New Pit", new_pit_path, class: "btn btn-default" %>
<br>
<br>
<% @pit.each do |pit| %>
<div class = "row">
<div class = "container">
<div class = "well pit-well">
<h3 id="pit-title"><%= link_to pit.topic, pit_path(pit) %></h3>
<p>by <%= link_to pit.author, '#' %></p>
<br>
<p><%= pit.summary %></p>
<p>Replies (<%= pit.comments.count %>)</p>
<br>
<p>Pit Created by: <%= link_to pit.user.name, current_user %> on <%= pit.created_at %></p>
<%= link_to "Join Pit", '#', class: "btn btn-primary" %>
</div>
</div>
<% end %>
</div>
</div>