我遇到了will_paginate gem的问题,因为分页链接没有出现在Heroku制作中。它在当地环境中完美运作。
一般信息
的Gemfile
gem 'rails', '3.2.3'
group :development do
gem 'sqlite3'
end
group :production do
gem 'pg'
end
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'twitter-bootstrap-rails'
gem 'therubyracer', :platform => :ruby
gem 'less'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
gem 'opentok'
gem 'redcarpet', '1.17.2'
gem 'will_paginate', "~> 3.0.3"
gem 'bcrypt-ruby', :require => "bcrypt"
的environment.rb
require 'will_paginate/array'
Posts_Controller.rb
def index
@posts = Post.paginate(:page => params[:page], :per_page => 10, :order => 'created_at DESC')
respond_to do |format|
format.html # index.html.erb
format.json { render json: @posts }
end
end
Index.html.erb(主题)
<%= will_paginate @posts %>
<%= render 'post' %>
_Post.html.erb
<% @posts.each do |post| %>
<h1><%= link_to post.title, post_path(post) %></h1>
<p>Posted On: <%= post.created_at %></p>
<p>
<%= markdown(post.body) %>
</p>
<% if admin? %>
<%= link_to "Edit", edit_post_path(post), :class => "btn" %>
<%= link_to "Destroy", post_path(post), :method => :delete, :class => :destroy %>
<% end %>
<hr/>
如果您需要更多信息,请与我们联系!