will paginate - Rails 4 - will_paginate -


this first attempt using will_paginate (i know! have been??)

titles_controller.erb

  def index     @titles = title.active.sorted.paginate(:page => params[:page])   end 

index.html.erb

<% will_paginate @titles.each |title| %> 

error:

undefined method `total_pages' #<enumerator:0x00000002bacaf0> 

wtf doing wrong? in advance.

please read paginate docs. need write:

<%= will_paginate @posts %> 

there no need adding each.

so entire view like:

<% @titles.each |title| %>   <!-- smth title --> <% end %>  <%= will_paginate @titles %> 

Comments

Popular posts from this blog

php - get table cell data from and place a copy in another table -

javascript - Mootools wait with Fx.Morph start -

php - Navigate throught databse rows -