ruby - will_paginate gem rendering each entry 4 times rails -
i using will_paginate rails 4 , have following code in users controller:
def index @users = user.paginate(page: params[:page], :per_page => 10) end
and in view:
<% provide(:title, 'all users') %> <h1>all users</h1> <%= will_paginate %> <ul class="users"> <% @users.each |user| %> <%= render @users %> <% end %> </ul> <%= will_paginate %>
this renders users there 40 per page, not 10. each page has correct users 4 times. example renders users 1 .. 10 1 .. 10 again , on. there 101 users , if set per page limit 1 renders 101 pages 1 user on each page should limit > 1 , breaks.
any insight on how fix 10 users appear on each page appreciated.
i found mistake. need render @users once. hope works on side. :)
<ul class="users"> <%= render @users %> </ul>
also need render pagination following code
<%= will_paginate @users %>
Comments
Post a Comment