如何使用ACTS_AS_VOTABLE GEM将所有帖子投资为当前用户

发布于 2025-01-31 04:09:07 字数 30 浏览 1 评论 0原文

我想向用户投票的所有帖子,我该如何执行此操作。

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

青巷忧颜 2025-02-07 04:09:07

假设您有这样的模型

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

可以获取某些用户的所有投票帖子(例如current_user),

current_user.get_up_voted(Post)

请查看 docs

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文