This is my first attempt using will_paginate (I know! Where have I been??)
titles_controller.erb
def index
@titles = Title.active.sorted.paginate(:page => params[:page])
end
index.html.erb
<% will_paginate @titles.each do |title| %>
Error:
undefined method `total_pages' for #<Enumerator:0x00000002bacaf0>
WTF am I doing wrong? Thanks in advance.
Please read will paginate docs. You need to write:
<%= will_paginate @posts %>
There is no need for adding each
.
So entire view would look like:
<% @titles.each do |title| %>
<!-- do smth with title -->
<% end %>
<%= will_paginate @titles %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With