ruby-on-railsrubyrubygemsacts-as-votable

how to get all the posts upvoted be current user using acts_as_votable gem


i want to show all the posts users have upvoted on, how can I do this.


Solution

  • Let's say you have such models

    class Post < ApplicationRecord
      acts_as_votable
    end
    
    class User < ApplicationRecord
      acts_as_voter
    end
    

    To get all upvoted posts of some user (e.g. current_user)

    current_user.get_up_voted(Post)
    

    Please also look at the docs