This is my first attempt to use will_paginate (do I know where I was?)
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 the docs section. You need to write:
<%= will_paginate @posts %>
No need to add each .
each
Thus, the whole view will look like this:
<% @titles.each do |title| %> <!-- do smth with title --> <% end %> <%= will_paginate @titles %>
In your case, you do not need to write:
<%= will_paginate @titles %>
Since it is in the context of title_controller, will_paginate will assume that it is an available @titles variable. So you can simply write:
<%= will_paginate %>
Source: https://habr.com/ru/post/950293/More articles:Is the internal interface * less * accessible than the internal secure constructor? - protectedallocator_traits :: construct () vs allocator_traits :: allocate () - c ++What is kAudioSessionProperty_InputSources, is this really good? - iosUnexplained error: "Unexpected token after the end of markup extensions" - visual-studio-2010How to check if Masked text box is empty? - vb.netWhat can I do to speed up this code (string similarity)? - c ++When you scale the css3 element, what transition properties change? - cssCan I insert a large text value into SQL Server from ASP.net without having the entire file in memory on the web server? - c #How to override Spring @Autowire annotation and set null field? - springHow to update url hash correctly when selecting jQuery tab? - javascriptAll Articles