使用 vote_fu 设置 Rails 应用
我最近安装了 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
视图用于显示信息。您所描述的内容属于控制器,除非它超过几行代码。
如果您发现控制器方法开始变得臃肿,请尝试考虑如何将该逻辑移至模型或模块中。
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.