I recently installed the will_paginate gem on my development blog and am having problems. I added it to my gemfile:
gem 'will_paginate'
then passed it to the message controller:
def index
@posts = Post.paginate(:per_page => 5, :page => params[:page], :order => 'created_at DESC')
respond_to do |format|
format.html
format.json { render json: @posts }
format.atom
end
end
and finally to the view:
<div id="post" style="background-color: gray; border-radius: 20px; border-bottom: solid black 2px; padding-bottom: 40px; padding-top: 40px; margin: auto;">
<%= post.content.html_safe %>
</div>
<br />
<div style="padding-bottom: 40px; background-color: brown;">
<li>Posted: <%= post.created_at.to_formatted_s(:long) %></li>
<li>Author: <%= post.author_name %></li>
<li>Comments: <%= post.comments.count %></li>
</div>
<br />
<br />
<%= will_paginate @posts %>
The index page is working fine. Currently, it is not paginated, because I do not have enough posts created in the development environment (I was going to create them through the admin panel, I ran into this). It also works great in the admin panel (using active_admin). This is only when I click on "messages" (or any other link) in the admin panel to create a new entry, I get the following error:
NoMethodError in Admin::PostsController#index
undefined method `per' for # <ActiveRecord::Relation::ActiveRecord_Relation_Post:0x5b37d30>
I am not sure how to proceed further, and appreciate any help. Sorry for the simple question.