Q:

undefined method `total_pages' for #

I would like to know if someone sees the problem
I am using the gem will_paginate
My Recipe model:
class Recipe < ActiveRecord::Base
  belongs_to :user
  has_many :ingredients, dependent: :destroy
  has_many :reviews, dependent: :destroy

  self.per_page = 10
end

My RecipesController:
class RecipesController < ApplicationController
  skip_before_action :authenticate_user!
  def index
    if params[:search]
      @recipes = Recipe.search(params[:search]).page(params[:page]).order("created_at DESC")
    else
      @recipes = Recipe.all.page(params[:page]).order('created_at DESC')
    end
  end

  def show
    @review = Review.new
    @recipe = Recipe.find(params[:id])
    @user = User.find(@recipe.user_id)
    @full_name = @recipe.user.first_name + " " + @recipe.user.last_name
  end
end

app/views/recipes/index.html.erb:
<%= will_paginate @recipes %>

A:

For the people who might care or have the same problem. I found the solution:
I changed self.per_page = 10 to WillPaginate.per_page = 10 inside the Recipe model.

