This code is working fine in first page but when I move on to the second and the other pages it shows them all without filtering
I am using gem "will_paginate", "~> 3.0.4"
in the controller
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
in the index
<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 %>