如何将will_paginate方法添加到rails中的条件

时间:2021-12-01 08:13:38

This is the controller where I want the paginate method to be applied.

这是我希望应用paginate方法的控制器。

I need the paginate method next to `@products = Product.where(value: @type.value).paginate(page: params[:page]) #But this is not working.

我需要`@products = Product.where(value:@ type.value).paginate(页面:params [:page])旁边的paginate方法#But这不起作用。

This is my controller [1]: https://i.stack.imgur.com/QlgGW.png

这是我的控制器[1]:https://i.stack.imgur.com/QlgGW.png

This is the error generated [2]: https://i.stack.imgur.com/f12py.png

这是生成的错误[2]:https://i.stack.imgur.com/f12py.png

Is there any way I can add the method without changing a lot of things.

有没有什么办法可以在不改变很多东西的情况下添加方法。

This is the Error I'm getting

The @product_types variable appears to be empty. Did you forget to pass the collection object for will_paginate?

@product_types变量似乎为空。你忘记了为will_paginate传递集合对象吗?

Extracted source (around line #17):

提取的来源(第17行):

</div>

<%= will_paginate %>

<div class="container">
    <div class="row">

1 个解决方案

#1


1  

#will_paginate expects a collection as argument.

#will_paginate期望一个集合作为参数。

<%= will_paginate @products %>

#1


1  

#will_paginate expects a collection as argument.

#will_paginate期望一个集合作为参数。

<%= will_paginate @products %>