没有任何数据可供显示
| 开源项目社区 | 当前位置 : |
|
| www.trustie.net/open_source_projects | 主页 > 开源项目社区 > actsasvoteable |
|
actsasvoteable
|
| 0 | 0 | 0 |
| 贡献者 | 讨论 | 代码提交 |
acts_as_voteable allows you to mix voting into your models:
Post < ActiveRecord::Base
acts_as_voteable
end
User < ActiveRecord::Base
acts_as_voter
end
#simple vote
user.vote_up(post)
user.vote_down(post)
#vote about something:
user.vote_up(post, :about => 'spam')
#check for a vote
user.voted_up?(post)
#count votes:
user.votes.count
user.up_votes.count
user.down_votes.count
#points (up - down)
user.points
#coming soon
user.points(:about => 'spam')
#sorting - works just like find from AR with a few changes
Post.find_top(:all, :since => 1.day.ago, :about => 'spam')
There are also generators for tests so you can verify that you installed correctly:
script/generate acts_as_voteable_test post
installation:
script/install plugin http://richcollins.net/svn/acts_as_voteable/
Send feedback to richcollins@gmail.com
Enjoy!
标签:
