I'm trying to do pagination for products details(images), but I'm getting this error.
NoMethodError in Home#index Showing /home/aws002/webpage/app/views/home/index.html.erb where line #6 raised: undefined method `current_page' for #
Here is my products controler code:
def index
@rroducts = Product.order(:name)
Kaminari.paginate_array(@products).page(params[:page]).per(3)
respond_to do |format|
format.html # index.html.erb
format.json { render json: @products }
end
end
and I'm trying to display in home page. view file code is:
<% @products=Product.all %>
<%= paginate @products %>
<% @products.each do |p|%>
<%= image_tag("Images/#{p.id}.jpeg",:alt => p.name) %>
<p> Price: </p>
<%= p.price %>
<p> Discount: </p>
<%= p.discount %>
<br/>
<% end %>
Please help me to fix this. Thanks in advance.