0

I am trying to use paginate with act as votable but I'm getting a few errors. My favorites method is to display a page that shows only items that the user upvoted.

  def favorites
    @title = "Favorites"
    @user = User.find(params[:id])
    @favorites = @user.find_up_voted_items
    render 'show_favorites'
  end

This shows all upvoted via act as votable items. However, when I try to use paginate on the page by editing the @ favorites with this:

@favorites = @user.find_up_voted_items.paginate(page: params[:page])

I get an undefined method for paginate.

I am already using paginate for other pages:

  def index
    @users = User.paginate(page: params[:page], per_page: 30)
  end

  def show
    @user = User.find(params[:id])
    @microposts = @user.microposts.paginate(page: params[:page])
  end

  def following
    @title = "Following"
    @user = User.find(params[:id])
    @users = @user.following.paginate(page: params[:page])
    render 'show_follow'
  end

  def followers
    @title = "Followers"
    @user = User.find(params[:id])
    @users = @user.followers.paginate(page: params[:page])
    render 'show_follow'
  end

What am I missing with my favorites method?

SJK
  • 135
  • 1
  • 10
  • Can you add the User model ? specifically the `find_up_voted_items` part – Roc Khalil Oct 26 '20 at 10:39
  • I have acts_as_voter in the user model along with has_many :favorites. I can display my favorites no problem, but for some reason it is not cooperating with paginate. I am not sure if I am not calling it right or there is something I forgot to add. – SJK Oct 26 '20 at 10:50

0 Answers0