提问人:nourza 提问时间:7/29/2023 最后编辑:nourza 更新时间:7/31/2023 访问量:26
ror 数据过滤器类别 gem 分页在第二页中不起作用
ror data-filter category gem pagination not working in the second page
问:
这段代码在第一页中工作正常,但是当我转到第二页和其他页面时,它会在没有过滤的情况下显示它们
我正在使用gem "will_paginate", "~> 3.0.4"
在控制器中
def index
@galleries=Gallery.paginate(page: params[:page], per_page: 19)
end
private
def gallery_attributes
gallery_attributes = params.require(:gallery).permit([:product_name,:image1,:image2,:image3,:image4,:image5,:title1,:title2,:title3,:title4,:title5,:video,:videotitle])
end
在索引中
<span class="list active" data-filter="all-items">All</span>
<% @galleries.select(:product_name).map(&:product_name).uniq.reject { |c| c.empty? }.each do |g| %>
<span class="list" data-filter="<%= g %>"><%= g %></span>
<% end %>
<% count = 1 %>
<% @galleries.each do |g| %>
<% if g.image1.present? %>
<div class="item <%= g.product_name %>">
<%= g.product_name %>
<%= image_tag g.image1.url,alt: "conversion", style: "width:100%", onclick: "openModal();currentSlide(#{count})" ,class: "hover-shadow cursor",alt: g.title1, title: g.title1%>
<p class="desc" onclick= "openModal();currentSlide(<%= count %>)" ><%= g.title1 %></p>
</div>
<% count = count + 1 %>
<% end %>
答: 暂无答案
评论
Gallery.paginate(...)
Gallery.all.paginate(...)
gallery_attributes
gallery_attributes