使用 vote_fu 设置 Rails 应用

发布于 2024-08-02 14:29:39 字数 498 浏览 6 评论 0原文

我最近安装了 http://github.com/peteonrails/vote_fu/tree/master (vote_fu)

在我一直在开发的一个应用程序上。

本质上,我只想要一个项目列表(例如,帖子)根据投票按降序显示。

我将acts_as_voteable 添加到posts 模型中,将acts_as_voter 添加到用户模型中。

从这里开始,我很困惑 - 我在教程中看到这个“voter.vote_for(voteablemodel)”,用于投票记录。但我不明白我应该在哪里实施它?

我应该将其添加到视图中,将其放入控制器中的新操作中吗?

显然我还是个新手 - 所以我为我在努力解决问题时提出的简单问题表示歉意。

提前致谢!

——埃利奥特

I've recently installed http://github.com/peteonrails/vote_fu/tree/master (vote_fu)

on an app I've been working on.

Essentially, I just want a list of items (lets say, posts for example) to display in descending order based on votes.

I added the acts_as_voteable to the posts model, and the acts_as_voter to the user model.

From here, I'm pretty confused - I see this "voter.vote_for(voteablemodel)" in the tutorial, for voting up a record. But I don't understan where I should be implementing it?

Should I just be adding it to a view, putting it in a new action in the controller?

I'm clearly still new - so i apologize for the simplistic questions as I struggle through.

Thanks in advance!

-Elliot

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

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

发布评论

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

评论(1

森林迷了鹿 2024-08-09 14:29:39

视图用于显示信息。您所描述的内容属于控制器,除非它超过几行代码。

如果您发现控制器方法开始变得臃肿,请尝试考虑如何将该逻辑移至模型或模块中。

Views are used for displaying information. What you're describing belongs in the controller unless it's more than a few lines of code.

If you see your controller methods start to become bloated, try to think of ways to move that logic into your model or a module.

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