ruby on rails - Kaminari not limiting collection in Spree -


for reason kaminari not limiting child objects on parent show view.

can see pagination links collection not limited.

what doing wrong?

view -

     <% if @handbag.microposts.any? %>         <h3>posts (<%= @handbag.microposts.count %>)</h3> <div class="row">   <div class="col-md-8">         <ol class="microposts">           <% @handbag.microposts.each |micropost| %>              <li id="micropost-<%= micropost.id %>">               <span class="user"><%= micropost.user.email %></span>               <span class="content"><%= micropost.content %></span>               <%= image_tag micropost.picture.url if micropost.picture? %>               <span class="timestamp">                 added <%= time_ago_in_words(micropost.created_at) %> ago.               </span>             </li>           <% end %>         </ol>       <%= paginate @microposts %> 

controller -

  def show     @handbag = spree::handbag.find(params[:id])     @microposts = @handbag.microposts.page(params[:page] || 1).per(10)   end 

thanks help.

you're looping through @handbag.microposts, entire collection, instead of @microposts, paginated collection.

so change @handbag.microposts.each @microposts.each


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -