Reputation: 1131
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.
Upvotes: 6
Views: 11074
Reputation: 31
In your case you dont acctually need to write:
<%= will_paginate @titles %>
Because it is in the context of the title_controller, will_paginate will assume their is a @titles variable available. Thus it is possible to just write:
<%= will_paginate %>
Upvotes: 3