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

Time:05-25

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

CodePudding user response:

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

  • Related